somexlab / fastddm

Python library for Differential Dynamic Microscopy analysis
https://fastddm.readthedocs.io/
GNU General Public License v3.0
3 stars 0 forks source link

Improve function readability #174

Closed enrico-lattuada closed 7 months ago

enrico-lattuada commented 11 months ago

Description Improve the readability and future maintenance of C++ and CUDA functions.

Proposed solution Split the elementary functions on C++ and CUDA side to be used from Python (e.g., FFT2, etc.).

Additional context Splitting the functions would allow us not only to improve the readability and future maintenance of the code but also to spot possible improvements in speed or accuracy, and write function tests.

enrico-lattuada commented 7 months ago

After a long struggle, I have found the problem with the CUDA-enabled library. Starting from Python 3.8, on Windows, the Path system variable is not used anymore to look for DLLs (in our case, for the CUDA Toolkit dynamic libraries). See here.

A possible workaround is to add the CUDA toolkit path to the DLL search using os.add_dll_directory() in the __init__.py file. For example, this solution works:

# non CUDA related imports
# ...

if IS_CUDA_ENABLED:
    import sys, os
    if sys.platform == "win32":
        # add the CUDA Toolkit bin directory, where the DLLs are stored
        os.add_dll_directory(os.path.join(os.environ["CUDA_PATH"], "bin"))
    # import the _core_gpu module
    # ...
enrico-lattuada commented 7 months ago

Closed by #175