HigherOrderCO/Bend

Error compiling cu generated code

Closed this issue · 2 comments

Reproducing the behavior

First of all, i have a really particular setup, so please test this in a more "normal" installation in order to check if it is really a bug or if its just a problem with my setup

The problem is the following:
Given a bend code, for example i will use the radix_sort.bend from /examples, if you generate the code with bend gen-cu radix_sort.bend > a.cu and after that you try to compile it on your own by using nvcc a.cu -o a you obtain the following error.

a.cu(2213): error: variable "BOOK_BUF" has already been defined
  static const u8 BOOK_BUF[] = {53, 0, 0, 0, 0, 0, 0, 0, 109, 97, 105, 110, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ...., 0, 0, 153, 1, 0, 0};
                  ^

1 error detected in the compilation of "a.cu".                                              

Then if we take a look into the a.cu and we search that part of the code we can see this

// Demos
// -----

  // stress_test 2^10 x 65536
  //static const u8 BOOK_BUF[] = {6, 0, 0, 0, 0, 0, 0, 0, 109, 97, 105, 110, 0, 0, .... ,0, 0, 0, 0, 0};

  // stress_test 2^18 x 65536
  static const u8 BOOK_BUF[] = {6, 0, 0, 0, 0, 0, 0, 0, 109, 97, 105, 110, 0, 0, ... , 0, 0, 0, 0};

  // bitonic_sort 2^20
  //static const u8 BOOK_BUF[] = {19, 0, 0, 0, 0, 0, 0, 0, 109, 97, 105, 110, 0, 0, ... ,0 , 0, 0, 80, 0, 0, 0};

static const u8 BOOK_BUF[] = {53, 0, 0, 0, 0, 0, 0, 0, 109, 97, 105, 110, 0, 0, ... , 153, 1, 0, 0};

// Main
// ----

The problem is originated due to the line under // stress_test 2^18 x 65536 not being commented since the start. It isnt really a big deal because you can open the generated code and comment it yourself, but its still a problem.

About the particular setup its the following:

  • Kali OS fully updated with the nvidia drivers and the cuda toolkit
  • The dockerized version of the compiler that can be downloaded by running docker pull docker.io/nschle/bend:12.4.1-devel-ubuntu22.04-devel

Then the exact steps done on my setup are the following:

Start the docker container (with a shared folder mounted)
docker run --name=bend2 --ipc=host --gpus all -it -v /home/your_user/Escritorio/bend:/workspace/shared docker.io/nschle/bend:12.4.1-devel-ubuntu22.04-devel /bin/bash

Once inside the docker compile the code from .bend to .cu.

Once the code is compiled go back to the original host and from there compile the .cu to a binary

The explanation to why doing such a setup is because of some problems trying to install bend on the host OS (which can happen in multiple OS, but it isnt the problem of this issue) and because of a bug in my particular install of docker (which recognizes the GPU but once you launch the command bend run-cu doesnt do nothing at all, but again this isnt the problem of this issue)

As i said in the first line please try to compile to .cu and then to binary as shown, do this steps in a more standard setup please, if its a bug of my special setup close this issue.

System Settings

  • Host OS: Kali GNU/Linux Rolling x86_64

  • Kernel Version: 6.6.15-amd64

  • CPU: AMD Ryzen 7 8845HS w/ Radeon 780M Graphics (16) @ 3.800GH

  • GPU: NVIDIA GeForce RTX 4070 Max-Q / Mobile

  • Nvidia drivers: NVIDIA-SMI 535.161.08 Driver Version: 535.161.08 CUDA Version: 12.2

  • Cuda Version: Cuda compilation tools, release 12.1, V12.1.105

  • Docker version: Docker version 26.1.3, build b72abbb

  • Docker image: docker.io/nschle/bend:12.4.1-devel-ubuntu22.04-devel github-repo: https://github.com/Wolfsauge/podman_build_bend

  • Docker HVM: hvm 2.0.17

  • Docker Bend: bend-lang 0.2.27

  • Docker Cuda version: Cuda compilation tools, release 12.4, V12.4.131

Additional context

No response

Oh thank you for pointing this out, this is indeed a problem, will be fixing it.

Closed by HigherOrderCO/HVM#364 (we still have to release it on crates in order for it to be effective on crates builds)