diff --git a/lib/gpu/Opencl.makefile b/lib/gpu/Opencl.makefile index a5fcde68f5..3e73e6256c 100644 --- a/lib/gpu/Opencl.makefile +++ b/lib/gpu/Opencl.makefile @@ -609,7 +609,7 @@ $(OBJ_DIR)/lal_lj_expand_coul_long.o: $(ALL_H) lal_lj_expand_coul_long.h lal_lj_ $(OBJ_DIR)/lal_lj_expand_coul_long_ext.o: $(ALL_H) lal_lj_expand_coul_long.h lal_lj_expand_coul_long_ext.cpp lal_base_charge.h $(OCL) -o $@ -c lal_lj_expand_coul_long_ext.cpp -I$(OBJ_DIR) -$(BIN_DIR)/ocl_get_devices: ./geryon/ucl_get_devices.cpp +$(BIN_DIR)/ocl_get_devices: ./geryon/ucl_get_devices.cpp $(OCL_H) $(OCL) -o $@ ./geryon/ucl_get_devices.cpp -DUCL_OPENCL $(OCL_LINK) $(OCL_LIB): $(OBJS) $(PTXS) diff --git a/lib/gpu/geryon/ocl_device.h b/lib/gpu/geryon/ocl_device.h index 584d04e616..2b2367545e 100644 --- a/lib/gpu/geryon/ocl_device.h +++ b/lib/gpu/geryon/ocl_device.h @@ -280,6 +280,9 @@ class UCL_Device { /// Return the OpenCL type for the device inline cl_device_id & cl_device() { return _cl_device; } + /// Select the platform that has accelerators + inline void set_platform_accelerator(int pid=-1); + private: int _num_platforms; // Number of platforms int _platform; // UCL_Device ID for current platform @@ -311,8 +314,8 @@ UCL_Device::UCL_Device() { return; } else _num_platforms=static_cast(nplatforms); - - set_platform(0); + // note that platform 0 may not necessarily be associated with accelerators + set_platform_accelerator(); } UCL_Device::~UCL_Device() { @@ -320,6 +323,7 @@ UCL_Device::~UCL_Device() { } void UCL_Device::clear() { + _properties.clear(); if (_device>-1) { for (size_t i=0; i<_cq.size(); i++) { CL_DESTRUCT_CALL(clReleaseCommandQueue(_cq.back())); @@ -529,75 +533,105 @@ int UCL_Device::set(int num) { return create_context(); } -// List all devices along with all properties +// List all devices from all platforms along with all properties void UCL_Device::print_all(std::ostream &out) { - if (num_devices() == 0) - out << "There is no device supporting OpenCL\n"; - for (int i=0; i