thorstone25 / qups

A MATLAB toolbox for prototyping and simulating diagnostic ultrasound imaging systems
Apache License 2.0
38 stars 20 forks source link

Windows Compilation #4

Closed apodkowa closed 2 years ago

apodkowa commented 2 years ago

Currently I have something working for Windows compilation in my fork. How best do you want to proceed in merging it?

thorstone25 commented 2 years ago

Thanks for figuring that out!

So it looks like to get this to work, you had to specify the nvcc binary as well as the c/c++ compiler binary (cl.exe). This is somewhat weird versus Linux, but it's the only thing supported on Windows, so that makes it easier.

I think the best way is to avoid further complexities with the other changes that need to be made is by moving the path name complexities to be the responsibility of the setup script rather than in the definitions for generating the compilation commands. It looks like a lot of the trouble is to get the correct paths (or environment variables?) for Windows. But once that's setup, I think the compilation code can remain simple e.g. avoid switching between strings and chars.

In either OS, the recompile code should generate a command that looks something like `"nvcc --ptx /home/user/qups/src/bf.cu -o /tmp/tp4d8e3d57_81a7_4920_a967_9a8e9ef582c6/bf.ptx --use_fast_math -Wno-deprecated-gpu-targets". Optionally, in the future, there can be defines appended for JIT compilation with static sizes or further math optimization, linking to CUDA libraries, etc. (hence why the command is generated using arrays of strings). I think this should still work on Windows if the proper paths are added. The call to nvcc should look basically the same.

It looks like the paths needed for Windows are related to the MSVC installation, as that's the only thing supported by Nvidia. I think the more robust approach is to put in the default path's for nvcc rather than require the user to find them, as the average user would likely just give up if prompted to manually search for a path on their computer. For more expert users, we can offer an option to specify the path on their install.

I made the changes to implement this. So far it still works on Linux with default paths by adding /usr/local/cuda/bin to the path. Judging by the search paths in your fork, I think this should still work by automatically finding the cl.exe and nvcc.exe paths on Windows. If the user needs to select the proper one, then they can input them directly at setup.

thorstone25 commented 2 years ago

@apodkowa if the current changes work for you, I'll close the issue.