|
@@ -37,12 +37,15 @@ extern "C" {
|
|
|
//========================================================================================================================================================================================================200
|
|
|
|
|
|
void
|
|
|
-kernel_gpu_opencl_wrapper( par_str par_cpu,
|
|
|
- dim_str dim_cpu,
|
|
|
- box_str* box_cpu,
|
|
|
- FOUR_VECTOR* rv_cpu,
|
|
|
- fp* qv_cpu,
|
|
|
- FOUR_VECTOR* fv_cpu)
|
|
|
+kernel_gpu_opencl_wrapper(par_str par_cpu,
|
|
|
+ dim_str dim_cpu,
|
|
|
+ box_str* box_cpu,
|
|
|
+ FOUR_VECTOR* rv_cpu,
|
|
|
+ fp* qv_cpu,
|
|
|
+ FOUR_VECTOR* fv_cpu,
|
|
|
+ int platform_id,
|
|
|
+ int device_id,
|
|
|
+ int use_gpu)
|
|
|
{
|
|
|
|
|
|
//======================================================================================================================================================150
|
|
@@ -91,8 +94,8 @@ kernel_gpu_opencl_wrapper( par_str par_cpu,
|
|
|
if (error != CL_SUCCESS)
|
|
|
fatal_CL(error, __LINE__);
|
|
|
|
|
|
- // Select the 1st platform
|
|
|
- cl_platform_id platform = platforms[1];
|
|
|
+ // Select the platform in accordance to platform_id passed as parameter
|
|
|
+ cl_platform_id platform = platforms[platform_id];
|
|
|
|
|
|
// Get the name of the selected platform and print it (if there are multiple platforms, choose the first one)
|
|
|
char pbuf[100];
|
|
@@ -109,18 +112,21 @@ kernel_gpu_opencl_wrapper( par_str par_cpu,
|
|
|
// CREATE CONTEXT FOR THE PLATFORM
|
|
|
//====================================================================================================100
|
|
|
|
|
|
+ // Selector for the device type in accordance to what passed as parameter
|
|
|
+ cl_device_type device_type = use_gpu ? CL_DEVICE_TYPE_GPU : CL_DEVICE_TYPE_CPU;
|
|
|
+
|
|
|
// Create context properties for selected platform
|
|
|
cl_context_properties context_properties[3] = { CL_CONTEXT_PLATFORM,
|
|
|
(cl_context_properties) platform,
|
|
|
0};
|
|
|
|
|
|
- // Create context for selected platform being GPU
|
|
|
+ // Create context for selected platform being CPU/GPU
|
|
|
cl_context context;
|
|
|
- context = clCreateContextFromType( context_properties,
|
|
|
- CL_DEVICE_TYPE_CPU,
|
|
|
- NULL,
|
|
|
- NULL,
|
|
|
- &error);
|
|
|
+ context = clCreateContextFromType(context_properties,
|
|
|
+ device_type,
|
|
|
+ NULL,
|
|
|
+ NULL,
|
|
|
+ &error);
|
|
|
if (error != CL_SUCCESS)
|
|
|
fatal_CL(error, __LINE__);
|
|
|
|
|
@@ -148,9 +154,9 @@ kernel_gpu_opencl_wrapper( par_str par_cpu,
|
|
|
if (error != CL_SUCCESS)
|
|
|
fatal_CL(error, __LINE__);
|
|
|
|
|
|
- // Select the first device (previousely selected for the context) (if there are multiple devices, choose the first one)
|
|
|
+ // Select the device passed as parameter
|
|
|
cl_device_id device;
|
|
|
- device = devices[0];
|
|
|
+ device = devices[device_id];
|
|
|
|
|
|
// Get the name of the selected device (previousely selected for the context) and print it
|
|
|
error = clGetDeviceInfo(device,
|