Skip to content

Commit 20fae1c

Browse files
committed
added support for 'device' module for GPGPU OpenCL programs
1 parent 935232b commit 20fae1c

31 files changed

Lines changed: 376 additions & 75 deletions

File tree

CHANGES

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
* 2016.09.23 added support for 'device' module for GPGPU OpenCL programs
2+
13
* 2016.05.06 adding simple JULIA bench demo (after MIT visit)
24

35
* 2016.03.26 adding program static MILEPOST features

program/polybench-opencl-2dconv/.cm/meta.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@
5050
],
5151
"ignore_return_code": "no",
5252
"run_time": {
53+
"need_gpgpu_device":"opencl",
5354
"fine_grain_timer_file": "tmp-ck-timer.json",
5455
"run_cmd_main": "$#BIN_FILE#$ \"$#src_path#$2DConvolution.cl\"",
5556
"run_cmd_out1": "tmp-output1.tmp",

program/polybench-opencl-2dconv/2DConvolution.c

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -139,25 +139,43 @@ void init(DATA_TYPE* A)
139139

140140
void cl_initialization()
141141
{
142-
142+
/* Grigori Fursin added support for CK widgets */
143+
int gpgpu_platform_id=0;
144+
int gpgpu_device_id=0;
145+
146+
cl_platform_id* platforms;
147+
cl_device_id* devices;
148+
149+
cl_device_id device;
150+
151+
if (getenv("CK_GPGPU_PLATFORM_ID")!=NULL) gpgpu_platform_id=atol(getenv("CK_GPGPU_PLATFORM_ID"));
152+
if (getenv("CK_GPGPU_DEVICE_ID")!=NULL) gpgpu_device_id=atol(getenv("CK_GPGPU_DEVICE_ID"));
153+
154+
platforms = (cl_platform_id*) malloc(sizeof(cl_platform_id) * gpgpu_platform_id+1);
155+
devices = (cl_device_id*) malloc(sizeof(cl_device_id) * gpgpu_device_id+1);
156+
143157
// Get platform and device information
144-
err_code = clGetPlatformIDs(1, &platform_id, &num_platforms);
158+
err_code = clGetPlatformIDs(15, platforms, &num_platforms);
145159
if(err_code == CL_SUCCESS) printf("number of platforms is %d\n",num_platforms);
146160
else printf("Error getting platform IDs\n");
147161

148-
err_code = clGetPlatformInfo(platform_id,CL_PLATFORM_NAME, sizeof(str_temp), str_temp,NULL);
162+
platform_id=platforms[gpgpu_platform_id];
163+
164+
err_code = clGetPlatformInfo(platform_id, CL_PLATFORM_NAME, sizeof(str_temp), str_temp,NULL);
149165
if(err_code == CL_SUCCESS) printf("platform name is %s\n",str_temp);
150166
else printf("Error getting platform name\n");
151167

152168
err_code = clGetPlatformInfo(platform_id, CL_PLATFORM_VERSION, sizeof(str_temp), str_temp,NULL);
153169
if(err_code == CL_SUCCESS) printf("platform version is %s\n",str_temp);
154170
else printf("Error getting platform version\n");
155171

156-
err_code = clGetDeviceIDs( platform_id, CL_DEVICE_TYPE_GPU, 1, &device_id, &num_devices);
172+
err_code = clGetDeviceIDs(platform_id, CL_DEVICE_TYPE_ALL, 15, devices, &num_devices);
157173
if(err_code == CL_SUCCESS) printf("number of devices is %d\n", num_devices);
158174
else printf("Error getting device IDs\n");
159175

160-
err_code = clGetDeviceInfo(device_id,CL_DEVICE_NAME, sizeof(str_temp), str_temp,NULL);
176+
device_id=devices[gpgpu_device_id];
177+
178+
err_code = clGetDeviceInfo(device_id, CL_DEVICE_NAME, sizeof(str_temp), str_temp,NULL);
161179
if(err_code == CL_SUCCESS) printf("device name is %s\n",str_temp);
162180
else printf("Error getting device name\n");
163181

program/polybench-opencl-2mm/.cm/meta.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@
5252
],
5353
"ignore_return_code": "no",
5454
"run_time": {
55+
"need_gpgpu_device":"opencl",
5556
"fine_grain_timer_file": "tmp-ck-timer.json",
5657
"run_cmd_main": "$#BIN_FILE#$ \"$#src_path#$2mm.cl\"",
5758
"run_cmd_out1": "tmp-output1.tmp",

program/polybench-opencl-2mm/2mm.c

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -172,25 +172,44 @@ void init_array(DATA_TYPE* A, DATA_TYPE* B, DATA_TYPE* C, DATA_TYPE* D)
172172

173173

174174
void cl_initialization()
175-
{
175+
{
176+
/* Grigori Fursin added support for CK widgets */
177+
int gpgpu_platform_id=0;
178+
int gpgpu_device_id=0;
179+
180+
cl_platform_id* platforms;
181+
cl_device_id* devices;
182+
183+
cl_device_id device;
184+
185+
if (getenv("CK_GPGPU_PLATFORM_ID")!=NULL) gpgpu_platform_id=atol(getenv("CK_GPGPU_PLATFORM_ID"));
186+
if (getenv("CK_GPGPU_DEVICE_ID")!=NULL) gpgpu_device_id=atol(getenv("CK_GPGPU_DEVICE_ID"));
187+
188+
platforms = (cl_platform_id*) malloc(sizeof(cl_platform_id) * gpgpu_platform_id+1);
189+
devices = (cl_device_id*) malloc(sizeof(cl_device_id) * gpgpu_device_id+1);
190+
176191
// Get platform and device information
177-
err_code = clGetPlatformIDs(1, &platform_id, &num_platforms);
192+
err_code = clGetPlatformIDs(15, platforms, &num_platforms);
178193
if(err_code == CL_SUCCESS) printf("number of platforms is %d\n",num_platforms);
179194
else printf("Error getting platform IDs\n");
180195

181-
err_code = clGetPlatformInfo(platform_id,CL_PLATFORM_NAME, sizeof(str_temp), str_temp,NULL);
196+
platform_id=platforms[gpgpu_platform_id];
197+
198+
err_code = clGetPlatformInfo(platform_id, CL_PLATFORM_NAME, sizeof(str_temp), str_temp,NULL);
182199
if(err_code == CL_SUCCESS) printf("platform name is %s\n",str_temp);
183200
else printf("Error getting platform name\n");
184201

185202
err_code = clGetPlatformInfo(platform_id, CL_PLATFORM_VERSION, sizeof(str_temp), str_temp,NULL);
186203
if(err_code == CL_SUCCESS) printf("platform version is %s\n",str_temp);
187204
else printf("Error getting platform version\n");
188205

189-
err_code = clGetDeviceIDs( platform_id, CL_DEVICE_TYPE_GPU, 1, &device_id, &num_devices);
206+
err_code = clGetDeviceIDs(platform_id, CL_DEVICE_TYPE_ALL, 15, devices, &num_devices);
190207
if(err_code == CL_SUCCESS) printf("number of devices is %d\n", num_devices);
191208
else printf("Error getting device IDs\n");
192209

193-
err_code = clGetDeviceInfo(device_id,CL_DEVICE_NAME, sizeof(str_temp), str_temp,NULL);
210+
device_id=devices[gpgpu_device_id];
211+
212+
err_code = clGetDeviceInfo(device_id, CL_DEVICE_NAME, sizeof(str_temp), str_temp,NULL);
194213
if(err_code == CL_SUCCESS) printf("device name is %s\n",str_temp);
195214
else printf("Error getting device name\n");
196215

program/polybench-opencl-3dconv/.cm/meta.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@
5151
],
5252
"ignore_return_code": "no",
5353
"run_time": {
54+
"need_gpgpu_device":"opencl",
5455
"fine_grain_timer_file": "tmp-ck-timer.json",
5556
"run_cmd_main": "$#BIN_FILE#$ \"$#src_path#$3DConvolution.cl\"",
5657
"run_cmd_out1": "tmp-output1.tmp",

program/polybench-opencl-3dconv/3DConvolution.c

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -120,25 +120,44 @@ void init(DATA_TYPE* A)
120120

121121

122122
void cl_initialization()
123-
{
123+
{
124+
/* Grigori Fursin added support for CK widgets */
125+
int gpgpu_platform_id=0;
126+
int gpgpu_device_id=0;
127+
128+
cl_platform_id* platforms;
129+
cl_device_id* devices;
130+
131+
cl_device_id device;
132+
133+
if (getenv("CK_GPGPU_PLATFORM_ID")!=NULL) gpgpu_platform_id=atol(getenv("CK_GPGPU_PLATFORM_ID"));
134+
if (getenv("CK_GPGPU_DEVICE_ID")!=NULL) gpgpu_device_id=atol(getenv("CK_GPGPU_DEVICE_ID"));
135+
136+
platforms = (cl_platform_id*) malloc(sizeof(cl_platform_id) * gpgpu_platform_id+1);
137+
devices = (cl_device_id*) malloc(sizeof(cl_device_id) * gpgpu_device_id+1);
138+
124139
// Get platform and device information
125-
err_code = clGetPlatformIDs(1, &platform_id, &num_platforms);
140+
err_code = clGetPlatformIDs(15, platforms, &num_platforms);
126141
if(err_code == CL_SUCCESS) printf("number of platforms is %d\n",num_platforms);
127142
else printf("Error getting platform IDs\n");
128143

129-
err_code = clGetPlatformInfo(platform_id,CL_PLATFORM_NAME, sizeof(str_temp), str_temp,NULL);
144+
platform_id=platforms[gpgpu_platform_id];
145+
146+
err_code = clGetPlatformInfo(platform_id, CL_PLATFORM_NAME, sizeof(str_temp), str_temp,NULL);
130147
if(err_code == CL_SUCCESS) printf("platform name is %s\n",str_temp);
131148
else printf("Error getting platform name\n");
132149

133150
err_code = clGetPlatformInfo(platform_id, CL_PLATFORM_VERSION, sizeof(str_temp), str_temp,NULL);
134151
if(err_code == CL_SUCCESS) printf("platform version is %s\n",str_temp);
135152
else printf("Error getting platform version\n");
136153

137-
err_code = clGetDeviceIDs( platform_id, CL_DEVICE_TYPE_GPU, 1, &device_id, &num_devices);
154+
err_code = clGetDeviceIDs(platform_id, CL_DEVICE_TYPE_ALL, 15, devices, &num_devices);
138155
if(err_code == CL_SUCCESS) printf("number of devices is %d\n", num_devices);
139156
else printf("Error getting device IDs\n");
140157

141-
err_code = clGetDeviceInfo(device_id,CL_DEVICE_NAME, sizeof(str_temp), str_temp,NULL);
158+
device_id=devices[gpgpu_device_id];
159+
160+
err_code = clGetDeviceInfo(device_id, CL_DEVICE_NAME, sizeof(str_temp), str_temp,NULL);
142161
if(err_code == CL_SUCCESS) printf("device name is %s\n",str_temp);
143162
else printf("Error getting device name\n");
144163

program/polybench-opencl-3mm/.cm/meta.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@
5353
],
5454
"ignore_return_code": "no",
5555
"run_time": {
56+
"need_gpgpu_device":"opencl",
5657
"fine_grain_timer_file": "tmp-ck-timer.json",
5758
"run_cmd_main": "$#BIN_FILE#$ \"$#src_path#$3mm.cl\"",
5859
"run_cmd_out1": "tmp-output1.tmp",

program/polybench-opencl-3mm/3mm.c

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -175,25 +175,44 @@ void init_array(DATA_TYPE* A, DATA_TYPE* B, DATA_TYPE* C, DATA_TYPE* D)
175175

176176

177177
void cl_initialization()
178-
{
178+
{
179+
/* Grigori Fursin added support for CK widgets */
180+
int gpgpu_platform_id=0;
181+
int gpgpu_device_id=0;
182+
183+
cl_platform_id* platforms;
184+
cl_device_id* devices;
185+
186+
cl_device_id device;
187+
188+
if (getenv("CK_GPGPU_PLATFORM_ID")!=NULL) gpgpu_platform_id=atol(getenv("CK_GPGPU_PLATFORM_ID"));
189+
if (getenv("CK_GPGPU_DEVICE_ID")!=NULL) gpgpu_device_id=atol(getenv("CK_GPGPU_DEVICE_ID"));
190+
191+
platforms = (cl_platform_id*) malloc(sizeof(cl_platform_id) * gpgpu_platform_id+1);
192+
devices = (cl_device_id*) malloc(sizeof(cl_device_id) * gpgpu_device_id+1);
193+
179194
// Get platform and device information
180-
err_code = clGetPlatformIDs(1, &platform_id, &num_platforms);
195+
err_code = clGetPlatformIDs(15, platforms, &num_platforms);
181196
if(err_code == CL_SUCCESS) printf("number of platforms is %d\n",num_platforms);
182197
else printf("Error getting platform IDs\n");
183198

184-
err_code = clGetPlatformInfo(platform_id,CL_PLATFORM_NAME, sizeof(str_temp), str_temp,NULL);
199+
platform_id=platforms[gpgpu_platform_id];
200+
201+
err_code = clGetPlatformInfo(platform_id, CL_PLATFORM_NAME, sizeof(str_temp), str_temp,NULL);
185202
if(err_code == CL_SUCCESS) printf("platform name is %s\n",str_temp);
186203
else printf("Error getting platform name\n");
187204

188205
err_code = clGetPlatformInfo(platform_id, CL_PLATFORM_VERSION, sizeof(str_temp), str_temp,NULL);
189206
if(err_code == CL_SUCCESS) printf("platform version is %s\n",str_temp);
190207
else printf("Error getting platform version\n");
191208

192-
err_code = clGetDeviceIDs( platform_id, CL_DEVICE_TYPE_GPU, 1, &device_id, &num_devices);
209+
err_code = clGetDeviceIDs(platform_id, CL_DEVICE_TYPE_ALL, 15, devices, &num_devices);
193210
if(err_code == CL_SUCCESS) printf("number of devices is %d\n", num_devices);
194211
else printf("Error getting device IDs\n");
195212

196-
err_code = clGetDeviceInfo(device_id,CL_DEVICE_NAME, sizeof(str_temp), str_temp,NULL);
213+
device_id=devices[gpgpu_device_id];
214+
215+
err_code = clGetDeviceInfo(device_id, CL_DEVICE_NAME, sizeof(str_temp), str_temp,NULL);
197216
if(err_code == CL_SUCCESS) printf("device name is %s\n",str_temp);
198217
else printf("Error getting device name\n");
199218

program/polybench-opencl-atax/.cm/meta.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@
5050
],
5151
"ignore_return_code": "no",
5252
"run_time": {
53+
"need_gpgpu_device":"opencl",
5354
"fine_grain_timer_file": "tmp-ck-timer.json",
5455
"run_cmd_main": "$#BIN_FILE#$ \"$#src_path#$atax.cl\"",
5556
"run_cmd_out1": "tmp-output1.tmp",

0 commit comments

Comments
 (0)