diff --git a/setup.py b/setup.py index 68d51a08b2d9e1cf1cb180ce2cc6f4e582a7e492..1e43659bee4fc208be5d83be616d46a758f74d76 100644 --- a/setup.py +++ b/setup.py @@ -26,6 +26,7 @@ def get_config_schema(): Switch("CL_TRACE", False, "Enable OpenCL API tracing"), Switch("CL_ENABLE_GL", False, "Enable OpenCL<->OpenGL interoperability"), + Switch("CL_ENABLE_DEVICE_FISSION", True, "Enable device fission extension, if present"), IncludeDir("CL", []), LibraryDir("CL", []), @@ -65,13 +66,16 @@ def main(): if conf["CL_TRACE"]: EXTRA_DEFINES["PYOPENCL_TRACE"] = 1 - INCLUDE_DIRS = ['src/cpp'] + conf["BOOST_INC_DIR"] + conf["CL_INC_DIR"] + INCLUDE_DIRS = conf["BOOST_INC_DIR"] + conf["CL_INC_DIR"] ext_kwargs = dict() if conf["CL_ENABLE_GL"]: EXTRA_DEFINES["HAVE_GL"] = 1 + if conf["CL_ENABLE_DEVICE_FISSION"]: + EXTRA_DEFINES["PYOPENCL_USE_DEVICE_FISSION"] = 1 + ver_dic = {} exec(compile(open("pyopencl/version.py").read(), "pyopencl/version.py", 'exec'), ver_dic) diff --git a/src/wrapper/wrap_cl.hpp b/src/wrapper/wrap_cl.hpp index 855deb924b811ad27385036629ea9ee1837e6fc2..2356d7df291d749860911087d9afdc837ef90d58 100644 --- a/src/wrapper/wrap_cl.hpp +++ b/src/wrapper/wrap_cl.hpp @@ -20,7 +20,6 @@ // elsewhere ------------------------------------------------------------------ #include -// TBD: Nvidia used to not install cl_ext.h by default. Grr. #include #if defined(_WIN32) @@ -369,7 +368,7 @@ namespace pyopencl { if (ownable_reference) { -#ifdef cl_ext_device_fission +#if defined(cl_ext_device_fission) && defined(PYOPENCL_USE_DEVICE_FISSION) if (retain) { clRetainDeviceEXT_fn cl_retain_device @@ -391,7 +390,7 @@ namespace pyopencl ~device() { -#ifdef cl_ext_device_fission +#if defined(cl_ext_device_fission) && defined(PYOPENCL_USE_DEVICE_FISSION) if (m_ownable_reference) { clReleaseDeviceEXT_fn cl_release_device @@ -523,7 +522,7 @@ namespace pyopencl case CL_DEVICE_INTEGRATED_MEMORY_NV: DEV_GET_INT_INF(cl_bool); #endif -#ifdef cl_ext_device_fission +#if defined(cl_ext_device_fission) && defined(PYOPENCL_USE_DEVICE_FISSION) case CL_DEVICE_PARENT_DEVICE_EXT: PYOPENCL_GET_OPAQUE_INFO(Device, m_device, param_name, cl_device_id, device); case CL_DEVICE_PARTITION_TYPES_EXT: @@ -542,7 +541,7 @@ namespace pyopencl } } -#ifdef cl_ext_device_fission +#if defined(cl_ext_device_fission) && defined(PYOPENCL_USE_DEVICE_FISSION) py::list create_sub_devices(py::object py_properties) { std::vector properties; diff --git a/src/wrapper/wrap_cl_part_1.cpp b/src/wrapper/wrap_cl_part_1.cpp index 7121fb7cee5500618869be7e79a0eb0394bd5be4..701b5099325437ce43674ab6e2fbe2b01c73cb9b 100644 --- a/src/wrapper/wrap_cl_part_1.cpp +++ b/src/wrapper/wrap_cl_part_1.cpp @@ -37,7 +37,7 @@ void pyopencl_expose_part_1() .add_property("obj_ptr", &cls::obj_ptr) .def(py::self == py::self) .def(py::self != py::self) -#ifdef cl_ext_device_fission +#if defined(cl_ext_device_fission) && defined(PYOPENCL_USE_DEVICE_FISSION) .DEF_SIMPLE_METHOD(create_sub_devices) #endif ; diff --git a/src/wrapper/wrap_constants.cpp b/src/wrapper/wrap_constants.cpp index cc8cc52b02678273c046aaacb4fda198325b7569..7375647bf27390dbb159aa50a736e80e10f87ea6 100644 --- a/src/wrapper/wrap_constants.cpp +++ b/src/wrapper/wrap_constants.cpp @@ -178,7 +178,7 @@ void pyopencl_expose_constants() ADD_ATTR(, INVALID_GLOBAL_WORK_SIZE); #endif -#ifdef cl_ext_device_fission +#if defined(cl_ext_device_fission) && defined(PYOPENCL_USE_DEVICE_FISSION) ADD_ATTR(, DEVICE_PARTITION_FAILED_EXT); ADD_ATTR(, INVALID_PARTITION_COUNT_EXT); ADD_ATTR(, INVALID_PARTITION_NAME_EXT); @@ -290,7 +290,7 @@ void pyopencl_expose_constants() #ifdef CL_DEVICE_PROFILING_TIMER_OFFSET_AMD ADD_ATTR(DEVICE_, PROFILING_TIMER_OFFSET_AMD); #endif -#ifdef cl_ext_device_fission +#if defined(cl_ext_device_fission) && defined(PYOPENCL_USE_DEVICE_FISSION) ADD_ATTR(DEVICE_, PARENT_DEVICE_EXT); ADD_ATTR(DEVICE_, PARTITION_TYPES_EXT); ADD_ATTR(DEVICE_, AFFINITY_DOMAINS_EXT); @@ -600,7 +600,7 @@ void pyopencl_expose_constants() { py::class_ cls( "device_partition_property_ext", py::no_init); -#ifdef cl_ext_device_fission +#if defined(cl_ext_device_fission) && defined(PYOPENCL_USE_DEVICE_FISSION) ADD_ATTR_SUFFIX(DEVICE_PARTITION_, EQUALLY, _EXT); ADD_ATTR_SUFFIX(DEVICE_PARTITION_, BY_COUNTS, _EXT); ADD_ATTR_SUFFIX(DEVICE_PARTITION_, BY_NAMES, _EXT); @@ -613,7 +613,7 @@ void pyopencl_expose_constants() { py::class_ cls("affinity_domain_ext", py::no_init); -#ifdef cl_ext_device_fission +#if defined(cl_ext_device_fission) && defined(PYOPENCL_USE_DEVICE_FISSION) ADD_ATTR_SUFFIX(AFFINITY_DOMAIN_, L1_CACHE, _EXT); ADD_ATTR_SUFFIX(AFFINITY_DOMAIN_, L2_CACHE, _EXT); ADD_ATTR_SUFFIX(AFFINITY_DOMAIN_, L3_CACHE, _EXT);