Skip to content

Commit e0536ab

Browse files
committed
Merge branch 'master' of github.com:IntelPython/pydppl
2 parents d34abc5 + 9a2fa1b commit e0536ab

File tree

4 files changed

+73
-0
lines changed

4 files changed

+73
-0
lines changed

conda-recipe/build.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ export OpenCL_LIBDIR=${DPCPP_ROOT}/lib
4141
export DPPL_ONEAPI_INTERFACE_LIBDIR=${PREFIX}/lib
4242
export DPPL_ONEAPI_INTERFACE_INCLDIR=${PREFIX}/include
4343

44+
4445
# FIXME: How to pass this using setup.py? This flags is needed when
4546
# dpcpp compiles the generated cpp file.
4647
export CFLAGS="-fPIC -O3 ${CFLAGS}"

dppl/ocldrv.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -429,6 +429,18 @@ def create_device_array(self, array):
429429

430430
return DeviceArray(self._env_ptr, array)
431431

432+
def device_support_int64_atomics(self):
433+
''' Returns True current device supports 64-bit int atomic operations
434+
'''
435+
436+
return self._env_ptr.support_int64_atomics
437+
438+
def device_support_float64_atomics(self):
439+
''' Returns True if current device supports 64-bit float atomic operations
440+
'''
441+
442+
return self._env_ptr.support_float64_atomics
443+
432444
def get_context_ptr(self):
433445
''' Returns a cdata wrapper for the OpenCL cl_context object.
434446
'''
@@ -541,6 +553,7 @@ def has_gpu_device(self):
541553

542554
return Runtime._gpu_device is not None
543555

556+
544557
def get_cpu_device(self):
545558
''' Returns a cdata wrapper for the first available OpenCL
546559
CPU context.

oneapi_wrapper/include/dppl_opencl_interface.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@ struct dp_env
4848
void *queue;
4949
unsigned int max_work_item_dims;
5050
size_t max_work_group_size;
51+
int support_int64_atomics;
52+
int support_float64_atomics;
5153
int (*dump_fn) (void *);
5254
};
5355

oneapi_wrapper/source/dppl_opencl_interface.c

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
//===----------------------------------------------------------------------===//
2626
#include "dppl_opencl_interface.h"
2727
#include "error_check_macros.h"
28+
#include <string.h>
2829
#include <assert.h>
2930
#include <CL/cl.h> /* OpenCL headers */
3031

@@ -277,6 +278,49 @@ static int get_first_device (cl_platform_id* platforms,
277278
return DP_GLUE_FAILURE;
278279
}
279280

281+
static int support_int64_atomics(cl_device_id *device)
282+
{
283+
284+
cl_int err;
285+
size_t size;
286+
char *value;
287+
288+
clGetDeviceInfo(*device, CL_DEVICE_EXTENSIONS, 0, NULL, &size);
289+
if (err != CL_SUCCESS ) {
290+
printf("Unable to obtain device info for param\n");
291+
return DP_GLUE_FAILURE;
292+
}
293+
value = (char*) malloc(size);
294+
clGetDeviceInfo(*device, CL_DEVICE_EXTENSIONS, size, value, NULL);
295+
296+
if(strstr(value, "cl_khr_int64_base_atomics") != NULL) {
297+
return DP_GLUE_SUCCESS;
298+
} else {
299+
return DP_GLUE_FAILURE;
300+
}
301+
}
302+
303+
static int support_float64_atomics(cl_device_id *device)
304+
{
305+
306+
cl_int err;
307+
size_t size;
308+
char *value;
309+
310+
clGetDeviceInfo(*device, CL_DEVICE_EXTENSIONS, 0, NULL, &size);
311+
if (err != CL_SUCCESS ) {
312+
printf("Unable to obtain device info for param\n");
313+
return DP_GLUE_FAILURE;
314+
}
315+
value = (char*) malloc(size);
316+
clGetDeviceInfo(*device, CL_DEVICE_EXTENSIONS, size, value, NULL);
317+
318+
if(strstr(value, "cl_khr_fp64") != NULL) {
319+
return DP_GLUE_SUCCESS;
320+
} else {
321+
return DP_GLUE_FAILURE;
322+
}
323+
}
280324

281325
/*!
282326
*
@@ -332,6 +376,19 @@ static int create_dp_env_t (cl_platform_id* platforms,
332376

333377
env->device = *device;
334378
env ->dump_fn = dump_device_info;
379+
380+
if (DP_GLUE_SUCCESS == support_int64_atomics(device)) {
381+
env->support_int64_atomics = 1;
382+
} else {
383+
env->support_int64_atomics = 0;
384+
}
385+
386+
if (DP_GLUE_SUCCESS == support_float64_atomics(device)) {
387+
env->support_float64_atomics = 1;
388+
} else {
389+
env->support_float64_atomics = 0;
390+
}
391+
335392
free(device);
336393
*env_t_ptr = env;
337394

0 commit comments

Comments
 (0)