Skip to content

Commit 281e955

Browse files
committed
Fixed maximum buffer allocation size limit in Intel CPU Runtime for OpenCL
1 parent c7e8987 commit 281e955

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/opencl.hpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ struct Device_Info {
110110
memory = (uint)(cl_device.getInfo<CL_DEVICE_GLOBAL_MEM_SIZE>()/1048576ull); // global memory in MB
111111
global_cache = (uint)(cl_device.getInfo<CL_DEVICE_GLOBAL_MEM_CACHE_SIZE>()/1024ull); // global cache in KB
112112
local_cache = (uint)(cl_device.getInfo<CL_DEVICE_LOCAL_MEM_SIZE>()/1024ull); // local cache in KB
113-
max_global_buffer = (uint)(cl_device.getInfo<CL_DEVICE_MAX_MEM_ALLOC_SIZE>()/1048576ull); // maximum global buffer size in MB
113+
max_global_buffer = (uint)(min(cl_device.getInfo<CL_DEVICE_MAX_MEM_ALLOC_SIZE>()/1048576ull, (ulong)memory)); // maximum global buffer size in MB
114114
max_constant_buffer = (uint)(cl_device.getInfo<CL_DEVICE_MAX_CONSTANT_BUFFER_SIZE>()/1024ull); // maximum constant buffer size in KB
115115
compute_units = (uint)cl_device.getInfo<CL_DEVICE_MAX_COMPUTE_UNITS>(); // compute units (CUs) can contain multiple cores depending on the microarchitecture
116116
clock_frequency = (uint)cl_device.getInfo<CL_DEVICE_MAX_CLOCK_FREQUENCY>(); // in MHz
@@ -176,6 +176,11 @@ inline void print_device_info(const Device_Info& d) { // print OpenCL device inf
176176
println("|----------------'------------------------------------------------------------|");
177177
}
178178
inline vector<Device_Info> get_devices(const bool print_info=true) { // returns a vector of all available OpenCL devices
179+
#if defined(_WIN32)
180+
(void)_putenv((char*)"CL_CONFIG_CPU_FORCE_MAX_MEM_ALLOC_SIZE=17179869183GB"); // fix maximum buffer allocation size limit in Intel CPU Runtime for OpenCL, 2^34-1 is max non-overflowing value
181+
#elif defined(__linux__)
182+
(void) putenv((char*)"CL_CONFIG_CPU_FORCE_MAX_MEM_ALLOC_SIZE=17179869183GB"); // fix maximum buffer allocation size limit in Intel CPU Runtime for OpenCL, 2^34-1 is max non-overflowing value
183+
#endif // Linux
179184
vector<Device_Info> devices; // get all devices of all platforms
180185
vector<cl::Platform> cl_platforms; // get all platforms (drivers)
181186
cl::Platform::get(&cl_platforms);

0 commit comments

Comments
 (0)