Skip to content

Commit

Permalink
comilation with OpenCL (only kd-trees)
Browse files Browse the repository at this point in the history
  • Loading branch information
Fabian Gieseke committed Oct 24, 2016
1 parent 9990b94 commit 6ba295a
Show file tree
Hide file tree
Showing 5 changed files with 142 additions and 130 deletions.
117 changes: 61 additions & 56 deletions bufferkdtree/neighbors/brute/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,63 +38,68 @@ def configuration(parent_package='', top_path=None):
from numpy.distutils.misc_util import Configuration
config = Configuration('neighbors/brute', parent_package, top_path)

# CPU + FLOAT
config.add_extension("_wrapper_cpu_float", \
sources=["swig/cpu_float.i"] + source_files_cpu,
swig_opts=swig_opts,
include_dirs=[numpy_include] + [include_paths],
define_macros=[
('SOURCE_PATH', os.path.join(SOURCES_RELATIVE_PATH, "neighbors/brute")),
('USE_GPU', 0),
('USE_DOUBLE', 0),
('TIMING', 1)
],
libraries=['OpenCL', 'gomp'],
extra_compile_args=["-fopenmp", '-O3', '-w'] + ['-I' + ipath for ipath in include_paths])

# CPU + DOUBLE
config.add_extension("_wrapper_cpu_double", \
sources=["swig/cpu_double.i"] + source_files_cpu,
swig_opts=swig_opts,
include_dirs=[numpy_include] + [include_paths],
define_macros=[
('SOURCE_PATH', os.path.join(SOURCES_RELATIVE_PATH, "neighbors/brute")),
('USE_GPU', 0),
('USE_DOUBLE', 1),
('TIMING', 1)
],
libraries=['OpenCL', 'gomp'],
extra_compile_args=["-fopenmp", '-O3', '-w'] + ['-I' + ipath for ipath in include_paths])
try:

# CPU + FLOAT
config.add_extension("_wrapper_cpu_float", \
sources=["swig/cpu_float.i"] + source_files_cpu,
swig_opts=swig_opts,
include_dirs=[numpy_include] + [include_paths],
define_macros=[
('SOURCE_PATH', os.path.join(SOURCES_RELATIVE_PATH, "neighbors/brute")),
('USE_GPU', 0),
('USE_DOUBLE', 0),
('TIMING', 1)
],
libraries=['OpenCL', 'gomp'],
extra_compile_args=["-fopenmp", '-O3', '-w'] + ['-I' + ipath for ipath in include_paths])

# GPU + FLOAT
config.add_extension("_wrapper_gpu_opencl_float", \
sources=["swig/gpu_float.i"] + source_files_opencl,
swig_opts=swig_opts,
include_dirs=[numpy_include] + [include_paths],
define_macros=[
('SOURCE_PATH', os.path.join(SOURCES_RELATIVE_PATH, "neighbors/brute")),
('USE_GPU', 1),
('USE_DOUBLE', 0),
('TIMING', 1),
('WORKGROUP_SIZE', 256)
],
libraries=['OpenCL', 'gomp'],
extra_compile_args=["-fopenmp", '-O3', '-w'] + ['-I' + ipath for ipath in include_paths])

# GPU + DOUBLE
config.add_extension("_wrapper_gpu_opencl_double", \
sources=["swig/gpu_double.i"] + source_files_opencl,
swig_opts=swig_opts,
include_dirs=[numpy_include] + [include_paths],
define_macros=[
('SOURCE_PATH', os.path.join(SOURCES_RELATIVE_PATH, "neighbors/brute")),
('USE_GPU', 1),
('USE_DOUBLE', 1),
('TIMING', 1),
('WORKGROUP_SIZE', 256)
],
libraries=['OpenCL', 'gomp'],
extra_compile_args=["-fopenmp", '-O3', '-w'] + ['-I' + ipath for ipath in include_paths])
# CPU + DOUBLE
config.add_extension("_wrapper_cpu_double", \
sources=["swig/cpu_double.i"] + source_files_cpu,
swig_opts=swig_opts,
include_dirs=[numpy_include] + [include_paths],
define_macros=[
('SOURCE_PATH', os.path.join(SOURCES_RELATIVE_PATH, "neighbors/brute")),
('USE_GPU', 0),
('USE_DOUBLE', 1),
('TIMING', 1)
],
libraries=['OpenCL', 'gomp'],
extra_compile_args=["-fopenmp", '-O3', '-w'] + ['-I' + ipath for ipath in include_paths])

# GPU + FLOAT
config.add_extension("_wrapper_gpu_opencl_float", \
sources=["swig/gpu_float.i"] + source_files_opencl,
swig_opts=swig_opts,
include_dirs=[numpy_include] + [include_paths],
define_macros=[
('SOURCE_PATH', os.path.join(SOURCES_RELATIVE_PATH, "neighbors/brute")),
('USE_GPU', 1),
('USE_DOUBLE', 0),
('TIMING', 1),
('WORKGROUP_SIZE', 256)
],
libraries=['OpenCL', 'gomp'],
extra_compile_args=["-fopenmp", '-O3', '-w'] + ['-I' + ipath for ipath in include_paths])

# GPU + DOUBLE
config.add_extension("_wrapper_gpu_opencl_double", \
sources=["swig/gpu_double.i"] + source_files_opencl,
swig_opts=swig_opts,
include_dirs=[numpy_include] + [include_paths],
define_macros=[
('SOURCE_PATH', os.path.join(SOURCES_RELATIVE_PATH, "neighbors/brute")),
('USE_GPU', 1),
('USE_DOUBLE', 1),
('TIMING', 1),
('WORKGROUP_SIZE', 256)
],
libraries=['OpenCL', 'gomp'],
extra_compile_args=["-fopenmp", '-O3', '-w'] + ['-I' + ipath for ipath in include_paths])
except:

print("\nWarning: Could not compile (OpenCL) implementation for brute-force implementation!\n")

return config

Expand Down
147 changes: 77 additions & 70 deletions bufferkdtree/neighbors/buffer_kdtree/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,78 +56,85 @@
swig_opts = ['-modern', '-threads']

def configuration(parent_package='', top_path=None):

from numpy.distutils.misc_util import Configuration
config = Configuration('neighbors/buffer_kdtree', parent_package, top_path)

# CPU + FLOAT
config.add_extension("_wrapper_cpu_float", \
sources=["swig/cpu_float.i"] + source_files_cpu,
swig_opts=swig_opts,
include_dirs=[numpy_include] + [include_paths],
define_macros=[
('SOURCE_PATH', os.path.join(SOURCES_RELATIVE_PATH, "neighbors/buffer_kdtree")),
('USE_DOUBLE', 0),
('TIMING', TIMING)
],
libraries=['OpenCL', 'gomp', 'm'],
extra_compile_args=["-fopenmp", '-O3', '-w'] + ['-I' + ipath for ipath in include_paths])

# CPU + DOUBLE
config.add_extension("_wrapper_cpu_double", \
sources=["swig/cpu_double.i"] + source_files_cpu,
swig_opts=swig_opts,
include_dirs=[numpy_include] + [include_paths],
define_macros=[
('SOURCE_PATH', os.path.join(SOURCES_RELATIVE_PATH, "neighbors/buffer_kdtree")),
('USE_DOUBLE', 1),
('TIMING', TIMING)
],
libraries=['OpenCL', 'gomp', 'm'],
extra_compile_args=["-fopenmp", '-O3', '-w'] + ['-I' + ipath for ipath in include_paths])

# GPU + FLOAT
config.add_extension("_wrapper_gpu_opencl_float", \
sources=["swig/gpu_float.i"] + source_files_opencl,
swig_opts=swig_opts,
include_dirs=[numpy_include] + [include_paths],
define_macros=[
('SOURCE_PATH', os.path.join(SOURCES_RELATIVE_PATH, "neighbors/buffer_kdtree")),
('USE_GPU', 1),
('USE_DOUBLE', 0),
('TIMING', TIMING),
('WORKGROUP_SIZE_BRUTE', WORKGROUP_SIZE_BRUTE),
('WORKGROUP_SIZE_LEAVES', WORKGROUP_SIZE_LEAVES),
('WORKGROUP_SIZE_UPDATE', WORKGROUP_SIZE_UPDATE),
('WORKGROUP_SIZE_COPY_INIT', WORKGROUP_SIZE_COPY_INIT),
('WORKGROUP_SIZE_COMBINE', WORKGROUP_SIZE_COMBINE),
('WORKGROUP_SIZE_TEST_SUBSET', WORKGROUP_SIZE_TEST_SUBSET),
('WORKGROUP_SIZE_COPY_DISTS_INDICES', WORKGROUP_SIZE_COPY_DISTS_INDICES),
],
libraries=['OpenCL', 'gomp'],
extra_compile_args=["-fopenmp", '-O3', '-w'] + ['-I' + ipath for ipath in include_paths])

# GPU + DOUBLE
config.add_extension("_wrapper_gpu_opencl_double", \
sources=["swig/gpu_double.i"] + source_files_opencl,
swig_opts=swig_opts,
include_dirs=[numpy_include] + [include_paths],
define_macros=[
('SOURCE_PATH', os.path.join(SOURCES_RELATIVE_PATH, "neighbors/buffer_kdtree")),
('USE_GPU', 1),
('USE_DOUBLE', 1),
('TIMING', TIMING),
('WORKGROUP_SIZE_BRUTE', WORKGROUP_SIZE_BRUTE),
('WORKGROUP_SIZE_LEAVES', WORKGROUP_SIZE_LEAVES),
('WORKGROUP_SIZE_UPDATE', WORKGROUP_SIZE_UPDATE),
('WORKGROUP_SIZE_COPY_INIT', WORKGROUP_SIZE_COPY_INIT),
('WORKGROUP_SIZE_COMBINE', WORKGROUP_SIZE_COMBINE),
('WORKGROUP_SIZE_TEST_SUBSET', WORKGROUP_SIZE_TEST_SUBSET),
('WORKGROUP_SIZE_COPY_DISTS_INDICES', WORKGROUP_SIZE_COPY_DISTS_INDICES),
],
libraries=['OpenCL', 'gomp'],
extra_compile_args=["-fopenmp", '-O3', '-w'] + ['-I' + ipath for ipath in include_paths])


try:

# CPU + FLOAT
config.add_extension("_wrapper_cpu_float", \
sources=["swig/cpu_float.i"] + source_files_cpu,
swig_opts=swig_opts,
include_dirs=[numpy_include] + [include_paths],
define_macros=[
('SOURCE_PATH', os.path.join(SOURCES_RELATIVE_PATH, "neighbors/buffer_kdtree")),
('USE_DOUBLE', 0),
('TIMING', TIMING)
],
libraries=['OpenCL', 'gomp', 'm'],
extra_compile_args=["-fopenmp", '-O3', '-w'] + ['-I' + ipath for ipath in include_paths])

# CPU + DOUBLE
config.add_extension("_wrapper_cpu_double", \
sources=["swig/cpu_double.i"] + source_files_cpu,
swig_opts=swig_opts,
include_dirs=[numpy_include] + [include_paths],
define_macros=[
('SOURCE_PATH', os.path.join(SOURCES_RELATIVE_PATH, "neighbors/buffer_kdtree")),
('USE_DOUBLE', 1),
('TIMING', TIMING)
],
libraries=['OpenCL', 'gomp', 'm'],
extra_compile_args=["-fopenmp", '-O3', '-w'] + ['-I' + ipath for ipath in include_paths])


# GPU + FLOAT
config.add_extension("_wrapper_gpu_opencl_float", \
sources=["swig/gpu_float.i"] + source_files_opencl,
swig_opts=swig_opts,
include_dirs=[numpy_include] + [include_paths],
define_macros=[
('SOURCE_PATH', os.path.join(SOURCES_RELATIVE_PATH, "neighbors/buffer_kdtree")),
('USE_GPU', 1),
('USE_DOUBLE', 0),
('TIMING', TIMING),
('WORKGROUP_SIZE_BRUTE', WORKGROUP_SIZE_BRUTE),
('WORKGROUP_SIZE_LEAVES', WORKGROUP_SIZE_LEAVES),
('WORKGROUP_SIZE_UPDATE', WORKGROUP_SIZE_UPDATE),
('WORKGROUP_SIZE_COPY_INIT', WORKGROUP_SIZE_COPY_INIT),
('WORKGROUP_SIZE_COMBINE', WORKGROUP_SIZE_COMBINE),
('WORKGROUP_SIZE_TEST_SUBSET', WORKGROUP_SIZE_TEST_SUBSET),
('WORKGROUP_SIZE_COPY_DISTS_INDICES', WORKGROUP_SIZE_COPY_DISTS_INDICES),
],
libraries=['OpenCL', 'gomp'],
extra_compile_args=["-fopenmp", '-O3', '-w'] + ['-I' + ipath for ipath in include_paths])

# GPU + DOUBLE
config.add_extension("_wrapper_gpu_opencl_double", \
sources=["swig/gpu_double.i"] + source_files_opencl,
swig_opts=swig_opts,
include_dirs=[numpy_include] + [include_paths],
define_macros=[
('SOURCE_PATH', os.path.join(SOURCES_RELATIVE_PATH, "neighbors/buffer_kdtree")),
('USE_GPU', 1),
('USE_DOUBLE', 1),
('TIMING', TIMING),
('WORKGROUP_SIZE_BRUTE', WORKGROUP_SIZE_BRUTE),
('WORKGROUP_SIZE_LEAVES', WORKGROUP_SIZE_LEAVES),
('WORKGROUP_SIZE_UPDATE', WORKGROUP_SIZE_UPDATE),
('WORKGROUP_SIZE_COPY_INIT', WORKGROUP_SIZE_COPY_INIT),
('WORKGROUP_SIZE_COMBINE', WORKGROUP_SIZE_COMBINE),
('WORKGROUP_SIZE_TEST_SUBSET', WORKGROUP_SIZE_TEST_SUBSET),
('WORKGROUP_SIZE_COPY_DISTS_INDICES', WORKGROUP_SIZE_COPY_DISTS_INDICES),
],
libraries=['OpenCL', 'gomp'],
extra_compile_args=["-fopenmp", '-O3', '-w'] + ['-I' + ipath for ipath in include_paths])

except:

print("\nWarning: Could not compile (OpenCL) implementation for buffer k-d tree implementation!\n")

return config

if __name__ == '__main__':
Expand Down
2 changes: 1 addition & 1 deletion bufferkdtree/neighbors/kdtree/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def configuration(parent_package='', top_path=None):
from numpy.distutils.misc_util import Configuration

config = Configuration('neighbors/kdtree', parent_package, top_path)

# CPU + FLOAT
config.add_extension("_wrapper_cpu_float", \
sources=["swig/cpu_float.i"] + source_files,
Expand Down
2 changes: 1 addition & 1 deletion bufferkdtree/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def configuration(parent_package='', top_path=None):
config.add_subpackage('neighbors/buffer_kdtree', subpackage_path='neighbors/buffer_kdtree')
config.add_subpackage('tests')
config.add_subpackage('util')

return config

if __name__ == '__main__':
Expand Down
4 changes: 2 additions & 2 deletions docs/changes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ Release 1.2 (July 2016)
* Small bug fixes
* Fixed memory leak (`GH1 <https://github.com/gieseke/bufferkdtree/issues/1>`_)

Release 1.1.1 (Dezember 2015)
Release 1.1.1 (December 2015)
-----------------------------
* Updated documentation

Release 1.1 (Dezember 2015)
Release 1.1 (December 2015)
-----------------------------
* Fixed wrong parameter assignment in 'kneighbors' method of both neighbors/kd_tree/base.py and neighbors/buffer_kdtree/base.py
* Added Multi-GPU support to brute-force approach (for benchmark purposes)
Expand Down

0 comments on commit 6ba295a

Please sign in to comment.