monofuel / hippo

HIP / CUDA library for Nim
MIT License
45 stars 1 forks source link

HIP_PLATFORM=nvidia #1

Closed monofuel closed 4 months ago

monofuel commented 6 months ago
monofuel commented 6 months ago
Error: execution of an external compiler program 'hipcc -c -std=gnu++17 -funsigned-char  -pthread -I/opt/rocm/include -std=c++17   -I/home/monofuel/Documents/src/monofuel34089/Nim/lib -I/home/monofuel/Documents/src/monofuel34089/hippo/tests/hip -o /home/monofuel/.cache/nim/call_params_d/@m..@s..@s..@sNim@slib@ssystem@sexceptions.nim.cpp.o /home/monofuel/.cache/nim/call_params_d/@m..@s..@s..@sNim@slib@ssystem@sexceptions.nim.cpp' failed with exit code: 1

nvcc fatal   : Value 'gnu++17' is not defined for option 'std'

nvcc doesn't like the default std flag from cppXsupport

monofuel commented 6 months ago

vector_sum_cuda got it working with couple of hacks in https://github.com/monofuel/Nim/tree/hipcc-nvcc

The problem for nvcc (and for hipcc when using the nvcc backend), is that all compiler flags like -std and -pthreads needs to be wrapped with -Xcompiler="..." I made some changes in nim in this branchhttps://github.com/monofuel/Nim/tree/hipcc-nvcc to handle wrapping, but my changes are ugly. it needs to be done for both the compiler and the linker, it must include all passc and passl options

monofuel commented 6 months ago

nim ships a vccexe.exe to handle converting gcc style params to visual C++ params.

the -Xcompiler flags need to be set in 2 cases: when using nvcc directly, or when using hipcc when HIP_PLATFORM=nvidia

we could follow the vccexe pattern and make a similar utility for gpu compiler arguments

monofuel commented 4 months ago

turns out, does not need to be as complicated as vccexe

https://github.com/monofuel/Nim/commit/8e3afdfc235b7701e40a15a00b1e00fd81426bdb