zeam-vm / pelemay

Pelemay is a native compiler for Elixir, which generates SIMD instructions. It has a plan to generate for GPU code.
Apache License 2.0
186 stars 13 forks source link

Error when including a decimal #153

Open zacky1972 opened 3 years ago

zacky1972 commented 3 years ago

Describe the bug An error occurs when Enum.map of an anonymous function including a decimal

To Reproduce Steps to reproduce the behavior:

  1. Use Pelemay in the source code as follows:
defmodule M do
  import Pelemay

  defpelemay do

    def float_mult(list) do
      list
      |> Enum.map(& &1 * 2.0)
    end
  end
end
  1. Run in the command 'mix run -e "M.float_mult([1,2,3])'
  2. See an error:
Compiling 1 file (.ex)

== Compilation error in file lib/m.ex ==
** (SyntaxError) _build/dev/lib/pelemay/priv/pelemay_nif_elixir_m.ex:64:37: syntax error before: "0"
    (elixir 1.11.2) lib/code.ex:1172: Code.compile_file/2
    (pelemay 0.0.13) lib/pelemay/generator/interface.ex:84: Pelemay.Generator.Interface.generate/1
    (pelemay 0.0.13) lib/pelemay/generator.ex:178: Pelemay.Generator.generate/1
    (pelemay 0.0.13) expanding macro: Pelemay.defpelemay/1
    lib/m.ex:4: M (module)

Expected behavior No error occurs.

Screenshots None.

Desktop (please complete the following information):

Copy & paste the error log from Logger tagged [Pelemay]

== Compilation error in file lib/m.ex ==
** (SyntaxError) _build/dev/lib/pelemay/priv/pelemay_nif_elixir_m.ex:64:37: syntax error before: "0"
    (elixir 1.11.2) lib/code.ex:1172: Code.compile_file/2
    (pelemay 0.0.13) lib/pelemay/generator/interface.ex:84: Pelemay.Generator.Interface.generate/1
    (pelemay 0.0.13) lib/pelemay/generator.ex:178: Pelemay.Generator.generate/1
    (pelemay 0.0.13) expanding macro: Pelemay.defpelemay/1
    lib/m.ex:4: M (module)

CpuInfo.all_profile:

> CpuInfo.all_profile
%{
  compiler: %{
    apple_clang: [
      %{
        bin: "/usr/bin/clang",
        type: :apple_clang,
        version: "12.0.0",
        versions: "Apple clang version 12.0.0 (clang-1200.0.32.27)"
      }
    ],
    "apple_clang++": [
      %{
        bin: "/usr/bin/clang++",
        type: :"apple_clang++",
        version: "12.0.0",
        versions: "Apple clang version 12.0.0 (clang-1200.0.32.27)"
      }
    ],
    cc_env: [],
    cflags_env: "-I/usr/local/opt/llvm/include -I/usr/local/opt/sqlite/include -I/usr/local/opt/mysql@5.6/include -I/usr/local/opt/openblas/include -I/usr/local/opt/openssl@1.1/include -I/usr/local/opt/icu4c/include -I/usr/local/opt/lapack/include",
    clang: [
      %{
        bin: "/usr/local/opt/llvm/bin/clang",
        type: :clang,
        version: "11.0.0",
        versions: "clang version 11.0.0"
      }
    ],
    "clang++": [
      %{
        bin: "/usr/local/opt/llvm/bin/clang++",
        type: :"clang++",
        version: "11.0.0",
        versions: "clang version 11.0.0"
      }
    ],
    cxx_env: [],
    cxxflags_env: "",
    "g++": [
      %{
        bin: "/usr/bin/g++",
        type: :"apple_clang++",
        version: "12.0.0",
        versions: "Apple clang version 12.0.0 (clang-1200.0.32.27)"
      },
      %{
        bin: "/usr/local/bin/g++-7",
        type: :"g++",
        version: "7.5.0",
        versions: "g++-7 (Homebrew GCC 7.5.0_2) 7.5.0"
      },
      %{
        bin: "/usr/local/bin/g++-8",
        type: :"g++",
        version: "8.4.0",
        versions: "g++-8 (Homebrew GCC 8.4.0_1) 8.4.0"
      }
    ],
    gcc: [
      %{
        bin: "/usr/bin/gcc",
        type: :apple_clang,
        version: "12.0.0",
        versions: "Apple clang version 12.0.0 (clang-1200.0.32.27)"
      },
      %{
        bin: "/usr/local/bin/gcc-7",
        type: :gcc,
        version: "7.5.0",
        versions: "gcc-7 (Homebrew GCC 7.5.0_2) 7.5.0"
      },
      %{
        bin: "/usr/local/bin/gcc-8",
        type: :gcc,
        version: "8.4.0",
        versions: "gcc-8 (Homebrew GCC 8.4.0_1) 8.4.0"
      }
    ],
    ldflags_env: "-L/usr/local/opt/llvm/lib -L/usr/local/opt/sqlite/lib -L/usr/local/opt/mysql@5.6/lib -L/usr/local/opt/openblas/lib -L/usr/local/opt/openssl@1.1/lib -L/usr/local/opt/icu4c/lib -L/usr/local/opt/lapack/lib"
  },
  cpu: %{
    cpu_model: "18-Core Intel Xeon W",
    cpu_models: ["18-Core Intel Xeon W"],
    cpu_type: "x86_64",
    hyper_threading: :enabled,
    num_of_cores_of_a_processor: 18,
    num_of_ecores: 0,
    num_of_pcores: 0,
    num_of_processors: 1,
    num_of_threads_of_a_processor: 36,
    os_type: :macos,
    total_num_of_cores: 18,
    total_num_of_threads: 36
  },
  cuda: %{cuda: false},
  elixir: %{version: "1.11.2"},
  erlang: %{otp_version: 23},
  kernel: %{
    kernel_release: "20.1.0",
    kernel_version: "Darwin 20.1.0",
    system_version: "macOS 11.0.1 (20B50)"
  },
  metal: %{metal: true}
}

Additional context None.