taigw / GeodisTK

geodesic distance transform of 2d/3d images
MIT License
130 stars 35 forks source link

How to compile with openmp #12

Closed supratikbose closed 2 years ago

supratikbose commented 2 years ago

Hi, If I trying to modify the code to use openmp within geodesic3d_raster_scan (to calculate the 13 neigbors in parallel). However to trigger openmp, the cpp code should be copmpiled with "gcc -fopenmp" flag. Any Idea, how to do that while triggering "python setup.py build"? regards Supratik

supratikbose commented 2 years ago

I got the answer: extra_compile_args in module definition inside setup.py did the trick

module1 = Extension(module_name, include_dirs = [np.get_include(), './cpp'], sources = ['./cpp/util.cpp', './cpp/geodesic_distance_2d.cpp', './cpp/geodesic_distance_3d.cpp', './cpp/geodesic_distance.cpp', wrap_source], extra_compile_args = ["-fopenmp"])