I am not familiar with CUDA or OpenCL. I don't use them by programming in C, instead, with Python packages, only what I need to do is to install CUDA. I am trying to brute SHA-512 with Nim. At first, official package checksums, but I find it very slow. https://github.com/khchen/hashlib is much faster, however, I wonder whether it is possible to make it further, like, with https://github.com/bkerler/opencl_brute or https://github.com/BilawalAhmed0900/CudaSHA512. After failing with searching, and some directions from AI:
nvcc -c sha512.cu
nvcc -shared -o sha512.so sha512.obj -lcudart
nim c --passL:sha512.so sha512cuda.nim
(When I compile the Nim file importing types and functions with {.importc, cdecl.}, it compiles. But when I import that Nim file and call any function in it, GCC says like undefined reference to `sha512_digest') (In fact I am using windows, so I guess it is foolish to set output .so) I think I can ask it in the community: Is it possible to call CUDA or OpenCL functions (written in .cuh, .cu, or .cl files) from Nim? How do I achieve that? Please excuse me for not giving my code, for my whole way thying to do it is probably wrong. e.g. Using GCC as backend? Using .so library?Just my 2 cents
I used https://github.com/treeform/shady to move a multithreaded CPU bound nim algorithm to GLSL compute shader with success.
Surely you don't have the same flexibility and advance features of CUDA or OPENCL, but it's fast to work with.
Yes it's possible.
Cuda and OpenCL object files can be called from Nim as long as you can call them from C or C++.