diff --git a/gpuctypes/opencl.py b/gpuctypes/opencl.py index ef829c4..39c05bf 100644 --- a/gpuctypes/opencl.py +++ b/gpuctypes/opencl.py @@ -117,7 +117,8 @@ class Union(ctypes.Union, AsDictMixin): _libraries = {} -_libraries['libOpenCL.so'] = ctypes.CDLL('/usr/lib/x86_64-linux-gnu/libOpenCL.so') +#_libraries['libOpenCL.so'] = ctypes.CDLL('/usr/lib/x86_64-linux-gnu/libOpenCL.so') +_libraries['libOpenCL.so'] = ctypes.CDLL('/System/Library/Frameworks/OpenCL.framework/Versions/A/OpenCL') c_int128 = ctypes.c_ubyte*16 c_uint128 = c_int128 void = None @@ -320,15 +321,15 @@ class struct__cl_name_version(Structure): clReleaseDevice = _libraries['libOpenCL.so'].clReleaseDevice clReleaseDevice.restype = cl_int clReleaseDevice.argtypes = [cl_device_id] -clSetDefaultDeviceCommandQueue = _libraries['libOpenCL.so'].clSetDefaultDeviceCommandQueue -clSetDefaultDeviceCommandQueue.restype = cl_int -clSetDefaultDeviceCommandQueue.argtypes = [cl_context, cl_device_id, cl_command_queue] -clGetDeviceAndHostTimer = _libraries['libOpenCL.so'].clGetDeviceAndHostTimer -clGetDeviceAndHostTimer.restype = cl_int -clGetDeviceAndHostTimer.argtypes = [cl_device_id, ctypes.POINTER(ctypes.c_uint64), ctypes.POINTER(ctypes.c_uint64)] -clGetHostTimer = _libraries['libOpenCL.so'].clGetHostTimer -clGetHostTimer.restype = cl_int -clGetHostTimer.argtypes = [cl_device_id, ctypes.POINTER(ctypes.c_uint64)] +#clSetDefaultDeviceCommandQueue = _libraries['libOpenCL.so'].clSetDefaultDeviceCommandQueue +#clSetDefaultDeviceCommandQueue.restype = cl_int +#clSetDefaultDeviceCommandQueue.argtypes = [cl_context, cl_device_id, cl_command_queue] +#clGetDeviceAndHostTimer = _libraries['libOpenCL.so'].clGetDeviceAndHostTimer +#clGetDeviceAndHostTimer.restype = cl_int +#clGetDeviceAndHostTimer.argtypes = [cl_device_id, ctypes.POINTER(ctypes.c_uint64), ctypes.POINTER(ctypes.c_uint64)] +#clGetHostTimer = _libraries['libOpenCL.so'].clGetHostTimer +#clGetHostTimer.restype = cl_int +#clGetHostTimer.argtypes = [cl_device_id, ctypes.POINTER(ctypes.c_uint64)] clCreateContext = _libraries['libOpenCL.so'].clCreateContext clCreateContext.restype = cl_context clCreateContext.argtypes = [ctypes.POINTER(ctypes.c_int64), cl_uint, ctypes.POINTER(ctypes.POINTER(struct__cl_device_id)), ctypes.CFUNCTYPE(None, ctypes.POINTER(ctypes.c_char), ctypes.POINTER(None), ctypes.c_uint64, ctypes.POINTER(None)), ctypes.POINTER(None), ctypes.POINTER(ctypes.c_int32)] @@ -344,12 +345,12 @@ class struct__cl_name_version(Structure): clGetContextInfo = _libraries['libOpenCL.so'].clGetContextInfo clGetContextInfo.restype = cl_int clGetContextInfo.argtypes = [cl_context, cl_context_info, size_t, ctypes.POINTER(None), ctypes.POINTER(ctypes.c_uint64)] -clSetContextDestructorCallback = _libraries['libOpenCL.so'].clSetContextDestructorCallback -clSetContextDestructorCallback.restype = cl_int -clSetContextDestructorCallback.argtypes = [cl_context, ctypes.CFUNCTYPE(None, ctypes.POINTER(struct__cl_context), ctypes.POINTER(None)), ctypes.POINTER(None)] -clCreateCommandQueueWithProperties = _libraries['libOpenCL.so'].clCreateCommandQueueWithProperties -clCreateCommandQueueWithProperties.restype = cl_command_queue -clCreateCommandQueueWithProperties.argtypes = [cl_context, cl_device_id, ctypes.POINTER(ctypes.c_uint64), ctypes.POINTER(ctypes.c_int32)] +#clSetContextDestructorCallback = _libraries['libOpenCL.so'].clSetContextDestructorCallback +#clSetContextDestructorCallback.restype = cl_int +#clSetContextDestructorCallback.argtypes = [cl_context, ctypes.CFUNCTYPE(None, ctypes.POINTER(struct__cl_context), ctypes.POINTER(None)), ctypes.POINTER(None)] +#clCreateCommandQueueWithProperties = _libraries['libOpenCL.so'].clCreateCommandQueueWithProperties +#clCreateCommandQueueWithProperties.restype = cl_command_queue +#clCreateCommandQueueWithProperties.argtypes = [cl_context, cl_device_id, ctypes.POINTER(ctypes.c_uint64), ctypes.POINTER(ctypes.c_int32)] clRetainCommandQueue = _libraries['libOpenCL.so'].clRetainCommandQueue clRetainCommandQueue.restype = cl_int clRetainCommandQueue.argtypes = [cl_command_queue] @@ -368,15 +369,15 @@ class struct__cl_name_version(Structure): clCreateImage = _libraries['libOpenCL.so'].clCreateImage clCreateImage.restype = cl_mem clCreateImage.argtypes = [cl_context, cl_mem_flags, ctypes.POINTER(struct__cl_image_format), ctypes.POINTER(struct__cl_image_desc), ctypes.POINTER(None), ctypes.POINTER(ctypes.c_int32)] -clCreatePipe = _libraries['libOpenCL.so'].clCreatePipe -clCreatePipe.restype = cl_mem -clCreatePipe.argtypes = [cl_context, cl_mem_flags, cl_uint, cl_uint, ctypes.POINTER(ctypes.c_int64), ctypes.POINTER(ctypes.c_int32)] -clCreateBufferWithProperties = _libraries['libOpenCL.so'].clCreateBufferWithProperties -clCreateBufferWithProperties.restype = cl_mem -clCreateBufferWithProperties.argtypes = [cl_context, ctypes.POINTER(ctypes.c_uint64), cl_mem_flags, size_t, ctypes.POINTER(None), ctypes.POINTER(ctypes.c_int32)] -clCreateImageWithProperties = _libraries['libOpenCL.so'].clCreateImageWithProperties -clCreateImageWithProperties.restype = cl_mem -clCreateImageWithProperties.argtypes = [cl_context, ctypes.POINTER(ctypes.c_uint64), cl_mem_flags, ctypes.POINTER(struct__cl_image_format), ctypes.POINTER(struct__cl_image_desc), ctypes.POINTER(None), ctypes.POINTER(ctypes.c_int32)] +#clCreatePipe = _libraries['libOpenCL.so'].clCreatePipe +#clCreatePipe.restype = cl_mem +#clCreatePipe.argtypes = [cl_context, cl_mem_flags, cl_uint, cl_uint, ctypes.POINTER(ctypes.c_int64), ctypes.POINTER(ctypes.c_int32)] +#clCreateBufferWithProperties = _libraries['libOpenCL.so'].clCreateBufferWithProperties +#clCreateBufferWithProperties.restype = cl_mem +#clCreateBufferWithProperties.argtypes = [cl_context, ctypes.POINTER(ctypes.c_uint64), cl_mem_flags, size_t, ctypes.POINTER(None), ctypes.POINTER(ctypes.c_int32)] +#clCreateImageWithProperties = _libraries['libOpenCL.so'].clCreateImageWithProperties +#clCreateImageWithProperties.restype = cl_mem +#clCreateImageWithProperties.argtypes = [cl_context, ctypes.POINTER(ctypes.c_uint64), cl_mem_flags, ctypes.POINTER(struct__cl_image_format), ctypes.POINTER(struct__cl_image_desc), ctypes.POINTER(None), ctypes.POINTER(ctypes.c_int32)] clRetainMemObject = _libraries['libOpenCL.so'].clRetainMemObject clRetainMemObject.restype = cl_int clRetainMemObject.argtypes = [cl_mem] @@ -392,21 +393,21 @@ class struct__cl_name_version(Structure): clGetImageInfo = _libraries['libOpenCL.so'].clGetImageInfo clGetImageInfo.restype = cl_int clGetImageInfo.argtypes = [cl_mem, cl_image_info, size_t, ctypes.POINTER(None), ctypes.POINTER(ctypes.c_uint64)] -clGetPipeInfo = _libraries['libOpenCL.so'].clGetPipeInfo -clGetPipeInfo.restype = cl_int -clGetPipeInfo.argtypes = [cl_mem, cl_pipe_info, size_t, ctypes.POINTER(None), ctypes.POINTER(ctypes.c_uint64)] +#clGetPipeInfo = _libraries['libOpenCL.so'].clGetPipeInfo +#clGetPipeInfo.restype = cl_int +#clGetPipeInfo.argtypes = [cl_mem, cl_pipe_info, size_t, ctypes.POINTER(None), ctypes.POINTER(ctypes.c_uint64)] clSetMemObjectDestructorCallback = _libraries['libOpenCL.so'].clSetMemObjectDestructorCallback clSetMemObjectDestructorCallback.restype = cl_int clSetMemObjectDestructorCallback.argtypes = [cl_mem, ctypes.CFUNCTYPE(None, ctypes.POINTER(struct__cl_mem), ctypes.POINTER(None)), ctypes.POINTER(None)] -clSVMAlloc = _libraries['libOpenCL.so'].clSVMAlloc -clSVMAlloc.restype = ctypes.POINTER(None) -clSVMAlloc.argtypes = [cl_context, cl_svm_mem_flags, size_t, cl_uint] -clSVMFree = _libraries['libOpenCL.so'].clSVMFree -clSVMFree.restype = None -clSVMFree.argtypes = [cl_context, ctypes.POINTER(None)] -clCreateSamplerWithProperties = _libraries['libOpenCL.so'].clCreateSamplerWithProperties -clCreateSamplerWithProperties.restype = cl_sampler -clCreateSamplerWithProperties.argtypes = [cl_context, ctypes.POINTER(ctypes.c_uint64), ctypes.POINTER(ctypes.c_int32)] +#clSVMAlloc = _libraries['libOpenCL.so'].clSVMAlloc +#clSVMAlloc.restype = ctypes.POINTER(None) +#clSVMAlloc.argtypes = [cl_context, cl_svm_mem_flags, size_t, cl_uint] +#clSVMFree = _libraries['libOpenCL.so'].clSVMFree +#clSVMFree.restype = None +#clSVMFree.argtypes = [cl_context, ctypes.POINTER(None)] +#clCreateSamplerWithProperties = _libraries['libOpenCL.so'].clCreateSamplerWithProperties +#clCreateSamplerWithProperties.restype = cl_sampler +#clCreateSamplerWithProperties.argtypes = [cl_context, ctypes.POINTER(ctypes.c_uint64), ctypes.POINTER(ctypes.c_int32)] clRetainSampler = _libraries['libOpenCL.so'].clRetainSampler clRetainSampler.restype = cl_int clRetainSampler.argtypes = [cl_sampler] @@ -425,9 +426,9 @@ class struct__cl_name_version(Structure): clCreateProgramWithBuiltInKernels = _libraries['libOpenCL.so'].clCreateProgramWithBuiltInKernels clCreateProgramWithBuiltInKernels.restype = cl_program clCreateProgramWithBuiltInKernels.argtypes = [cl_context, cl_uint, ctypes.POINTER(ctypes.POINTER(struct__cl_device_id)), ctypes.POINTER(ctypes.c_char), ctypes.POINTER(ctypes.c_int32)] -clCreateProgramWithIL = _libraries['libOpenCL.so'].clCreateProgramWithIL -clCreateProgramWithIL.restype = cl_program -clCreateProgramWithIL.argtypes = [cl_context, ctypes.POINTER(None), size_t, ctypes.POINTER(ctypes.c_int32)] +#clCreateProgramWithIL = _libraries['libOpenCL.so'].clCreateProgramWithIL +#clCreateProgramWithIL.restype = cl_program +#clCreateProgramWithIL.argtypes = [cl_context, ctypes.POINTER(None), size_t, ctypes.POINTER(ctypes.c_int32)] clRetainProgram = _libraries['libOpenCL.so'].clRetainProgram clRetainProgram.restype = cl_int clRetainProgram.argtypes = [cl_program] @@ -443,12 +444,12 @@ class struct__cl_name_version(Structure): clLinkProgram = _libraries['libOpenCL.so'].clLinkProgram clLinkProgram.restype = cl_program clLinkProgram.argtypes = [cl_context, cl_uint, ctypes.POINTER(ctypes.POINTER(struct__cl_device_id)), ctypes.POINTER(ctypes.c_char), cl_uint, ctypes.POINTER(ctypes.POINTER(struct__cl_program)), ctypes.CFUNCTYPE(None, ctypes.POINTER(struct__cl_program), ctypes.POINTER(None)), ctypes.POINTER(None), ctypes.POINTER(ctypes.c_int32)] -clSetProgramReleaseCallback = _libraries['libOpenCL.so'].clSetProgramReleaseCallback -clSetProgramReleaseCallback.restype = cl_int -clSetProgramReleaseCallback.argtypes = [cl_program, ctypes.CFUNCTYPE(None, ctypes.POINTER(struct__cl_program), ctypes.POINTER(None)), ctypes.POINTER(None)] -clSetProgramSpecializationConstant = _libraries['libOpenCL.so'].clSetProgramSpecializationConstant -clSetProgramSpecializationConstant.restype = cl_int -clSetProgramSpecializationConstant.argtypes = [cl_program, cl_uint, size_t, ctypes.POINTER(None)] +#clSetProgramReleaseCallback = _libraries['libOpenCL.so'].clSetProgramReleaseCallback +#clSetProgramReleaseCallback.restype = cl_int +#clSetProgramReleaseCallback.argtypes = [cl_program, ctypes.CFUNCTYPE(None, ctypes.POINTER(struct__cl_program), ctypes.POINTER(None)), ctypes.POINTER(None)] +#clSetProgramSpecializationConstant = _libraries['libOpenCL.so'].clSetProgramSpecializationConstant +#clSetProgramSpecializationConstant.restype = cl_int +#clSetProgramSpecializationConstant.argtypes = [cl_program, cl_uint, size_t, ctypes.POINTER(None)] clUnloadPlatformCompiler = _libraries['libOpenCL.so'].clUnloadPlatformCompiler clUnloadPlatformCompiler.restype = cl_int clUnloadPlatformCompiler.argtypes = [cl_platform_id] @@ -464,9 +465,9 @@ class struct__cl_name_version(Structure): clCreateKernelsInProgram = _libraries['libOpenCL.so'].clCreateKernelsInProgram clCreateKernelsInProgram.restype = cl_int clCreateKernelsInProgram.argtypes = [cl_program, cl_uint, ctypes.POINTER(ctypes.POINTER(struct__cl_kernel)), ctypes.POINTER(ctypes.c_uint32)] -clCloneKernel = _libraries['libOpenCL.so'].clCloneKernel -clCloneKernel.restype = cl_kernel -clCloneKernel.argtypes = [cl_kernel, ctypes.POINTER(ctypes.c_int32)] +#clCloneKernel = _libraries['libOpenCL.so'].clCloneKernel +#clCloneKernel.restype = cl_kernel +#clCloneKernel.argtypes = [cl_kernel, ctypes.POINTER(ctypes.c_int32)] clRetainKernel = _libraries['libOpenCL.so'].clRetainKernel clRetainKernel.restype = cl_int clRetainKernel.argtypes = [cl_kernel] @@ -476,12 +477,12 @@ class struct__cl_name_version(Structure): clSetKernelArg = _libraries['libOpenCL.so'].clSetKernelArg clSetKernelArg.restype = cl_int clSetKernelArg.argtypes = [cl_kernel, cl_uint, size_t, ctypes.POINTER(None)] -clSetKernelArgSVMPointer = _libraries['libOpenCL.so'].clSetKernelArgSVMPointer -clSetKernelArgSVMPointer.restype = cl_int -clSetKernelArgSVMPointer.argtypes = [cl_kernel, cl_uint, ctypes.POINTER(None)] -clSetKernelExecInfo = _libraries['libOpenCL.so'].clSetKernelExecInfo -clSetKernelExecInfo.restype = cl_int -clSetKernelExecInfo.argtypes = [cl_kernel, cl_kernel_exec_info, size_t, ctypes.POINTER(None)] +#clSetKernelArgSVMPointer = _libraries['libOpenCL.so'].clSetKernelArgSVMPointer +#clSetKernelArgSVMPointer.restype = cl_int +#clSetKernelArgSVMPointer.argtypes = [cl_kernel, cl_uint, ctypes.POINTER(None)] +#clSetKernelExecInfo = _libraries['libOpenCL.so'].clSetKernelExecInfo +#clSetKernelExecInfo.restype = cl_int +#clSetKernelExecInfo.argtypes = [cl_kernel, cl_kernel_exec_info, size_t, ctypes.POINTER(None)] clGetKernelInfo = _libraries['libOpenCL.so'].clGetKernelInfo clGetKernelInfo.restype = cl_int clGetKernelInfo.argtypes = [cl_kernel, cl_kernel_info, size_t, ctypes.POINTER(None), ctypes.POINTER(ctypes.c_uint64)] @@ -491,9 +492,9 @@ class struct__cl_name_version(Structure): clGetKernelWorkGroupInfo = _libraries['libOpenCL.so'].clGetKernelWorkGroupInfo clGetKernelWorkGroupInfo.restype = cl_int clGetKernelWorkGroupInfo.argtypes = [cl_kernel, cl_device_id, cl_kernel_work_group_info, size_t, ctypes.POINTER(None), ctypes.POINTER(ctypes.c_uint64)] -clGetKernelSubGroupInfo = _libraries['libOpenCL.so'].clGetKernelSubGroupInfo -clGetKernelSubGroupInfo.restype = cl_int -clGetKernelSubGroupInfo.argtypes = [cl_kernel, cl_device_id, cl_kernel_sub_group_info, size_t, ctypes.POINTER(None), size_t, ctypes.POINTER(None), ctypes.POINTER(ctypes.c_uint64)] +#clGetKernelSubGroupInfo = _libraries['libOpenCL.so'].clGetKernelSubGroupInfo +#clGetKernelSubGroupInfo.restype = cl_int +#clGetKernelSubGroupInfo.argtypes = [cl_kernel, cl_device_id, cl_kernel_sub_group_info, size_t, ctypes.POINTER(None), size_t, ctypes.POINTER(None), ctypes.POINTER(ctypes.c_uint64)] clWaitForEvents = _libraries['libOpenCL.so'].clWaitForEvents clWaitForEvents.restype = cl_int clWaitForEvents.argtypes = [cl_uint, ctypes.POINTER(ctypes.POINTER(struct__cl_event))] @@ -587,24 +588,24 @@ class struct__cl_name_version(Structure): clEnqueueBarrierWithWaitList = _libraries['libOpenCL.so'].clEnqueueBarrierWithWaitList clEnqueueBarrierWithWaitList.restype = cl_int clEnqueueBarrierWithWaitList.argtypes = [cl_command_queue, cl_uint, ctypes.POINTER(ctypes.POINTER(struct__cl_event)), ctypes.POINTER(ctypes.POINTER(struct__cl_event))] -clEnqueueSVMFree = _libraries['libOpenCL.so'].clEnqueueSVMFree -clEnqueueSVMFree.restype = cl_int -clEnqueueSVMFree.argtypes = [cl_command_queue, cl_uint, ctypes.POINTER(None) * 0, ctypes.CFUNCTYPE(None, ctypes.POINTER(struct__cl_command_queue), ctypes.c_uint32, ctypes.POINTER(ctypes.POINTER(None)), ctypes.POINTER(None)), ctypes.POINTER(None), cl_uint, ctypes.POINTER(ctypes.POINTER(struct__cl_event)), ctypes.POINTER(ctypes.POINTER(struct__cl_event))] -clEnqueueSVMMemcpy = _libraries['libOpenCL.so'].clEnqueueSVMMemcpy -clEnqueueSVMMemcpy.restype = cl_int -clEnqueueSVMMemcpy.argtypes = [cl_command_queue, cl_bool, ctypes.POINTER(None), ctypes.POINTER(None), size_t, cl_uint, ctypes.POINTER(ctypes.POINTER(struct__cl_event)), ctypes.POINTER(ctypes.POINTER(struct__cl_event))] -clEnqueueSVMMemFill = _libraries['libOpenCL.so'].clEnqueueSVMMemFill -clEnqueueSVMMemFill.restype = cl_int -clEnqueueSVMMemFill.argtypes = [cl_command_queue, ctypes.POINTER(None), ctypes.POINTER(None), size_t, size_t, cl_uint, ctypes.POINTER(ctypes.POINTER(struct__cl_event)), ctypes.POINTER(ctypes.POINTER(struct__cl_event))] -clEnqueueSVMMap = _libraries['libOpenCL.so'].clEnqueueSVMMap -clEnqueueSVMMap.restype = cl_int -clEnqueueSVMMap.argtypes = [cl_command_queue, cl_bool, cl_map_flags, ctypes.POINTER(None), size_t, cl_uint, ctypes.POINTER(ctypes.POINTER(struct__cl_event)), ctypes.POINTER(ctypes.POINTER(struct__cl_event))] -clEnqueueSVMUnmap = _libraries['libOpenCL.so'].clEnqueueSVMUnmap -clEnqueueSVMUnmap.restype = cl_int -clEnqueueSVMUnmap.argtypes = [cl_command_queue, ctypes.POINTER(None), cl_uint, ctypes.POINTER(ctypes.POINTER(struct__cl_event)), ctypes.POINTER(ctypes.POINTER(struct__cl_event))] -clEnqueueSVMMigrateMem = _libraries['libOpenCL.so'].clEnqueueSVMMigrateMem -clEnqueueSVMMigrateMem.restype = cl_int -clEnqueueSVMMigrateMem.argtypes = [cl_command_queue, cl_uint, ctypes.POINTER(ctypes.POINTER(None)), ctypes.POINTER(ctypes.c_uint64), cl_mem_migration_flags, cl_uint, ctypes.POINTER(ctypes.POINTER(struct__cl_event)), ctypes.POINTER(ctypes.POINTER(struct__cl_event))] +#clEnqueueSVMFree = _libraries['libOpenCL.so'].clEnqueueSVMFree +#clEnqueueSVMFree.restype = cl_int +#clEnqueueSVMFree.argtypes = [cl_command_queue, cl_uint, ctypes.POINTER(None) * 0, ctypes.CFUNCTYPE(None, ctypes.POINTER(struct__cl_command_queue), ctypes.c_uint32, ctypes.POINTER(ctypes.POINTER(None)), ctypes.POINTER(None)), ctypes.POINTER(None), cl_uint, ctypes.POINTER(ctypes.POINTER(struct__cl_event)), ctypes.POINTER(ctypes.POINTER(struct__cl_event))] +#clEnqueueSVMMemcpy = _libraries['libOpenCL.so'].clEnqueueSVMMemcpy +#clEnqueueSVMMemcpy.restype = cl_int +#clEnqueueSVMMemcpy.argtypes = [cl_command_queue, cl_bool, ctypes.POINTER(None), ctypes.POINTER(None), size_t, cl_uint, ctypes.POINTER(ctypes.POINTER(struct__cl_event)), ctypes.POINTER(ctypes.POINTER(struct__cl_event))] +#clEnqueueSVMMemFill = _libraries['libOpenCL.so'].clEnqueueSVMMemFill +#clEnqueueSVMMemFill.restype = cl_int +#clEnqueueSVMMemFill.argtypes = [cl_command_queue, ctypes.POINTER(None), ctypes.POINTER(None), size_t, size_t, cl_uint, ctypes.POINTER(ctypes.POINTER(struct__cl_event)), ctypes.POINTER(ctypes.POINTER(struct__cl_event))] +#clEnqueueSVMMap = _libraries['libOpenCL.so'].clEnqueueSVMMap +#clEnqueueSVMMap.restype = cl_int +#clEnqueueSVMMap.argtypes = [cl_command_queue, cl_bool, cl_map_flags, ctypes.POINTER(None), size_t, cl_uint, ctypes.POINTER(ctypes.POINTER(struct__cl_event)), ctypes.POINTER(ctypes.POINTER(struct__cl_event))] +#clEnqueueSVMUnmap = _libraries['libOpenCL.so'].clEnqueueSVMUnmap +#clEnqueueSVMUnmap.restype = cl_int +#clEnqueueSVMUnmap.argtypes = [cl_command_queue, ctypes.POINTER(None), cl_uint, ctypes.POINTER(ctypes.POINTER(struct__cl_event)), ctypes.POINTER(ctypes.POINTER(struct__cl_event))] +#clEnqueueSVMMigrateMem = _libraries['libOpenCL.so'].clEnqueueSVMMigrateMem +#clEnqueueSVMMigrateMem.restype = cl_int +#clEnqueueSVMMigrateMem.argtypes = [cl_command_queue, cl_uint, ctypes.POINTER(ctypes.POINTER(None)), ctypes.POINTER(ctypes.c_uint64), cl_mem_migration_flags, cl_uint, ctypes.POINTER(ctypes.POINTER(struct__cl_event)), ctypes.POINTER(ctypes.POINTER(struct__cl_event))] clGetExtensionFunctionAddressForPlatform = _libraries['libOpenCL.so'].clGetExtensionFunctionAddressForPlatform clGetExtensionFunctionAddressForPlatform.restype = ctypes.POINTER(None) clGetExtensionFunctionAddressForPlatform.argtypes = [cl_platform_id, ctypes.POINTER(ctypes.c_char)] diff --git a/test/test_opencl.py b/test/test_opencl.py new file mode 100644 index 0000000..036f14c --- /dev/null +++ b/test/test_opencl.py @@ -0,0 +1,35 @@ +import ctypes +import unittest +# TODO: the import has to not fail if some of the methods are missing +import gpuctypes.opencl as cl + +def check(status): + if status != 0: raise RuntimeError(f"OpenCL Error {status}") + +# TODO: this should be in the header +CL_DEVICE_TYPE_DEFAULT = 1 + +class TestOpenCL(unittest.TestCase): + @classmethod + def setUpClass(cls): + num_platforms = ctypes.c_uint32() + platform_array = (cl.cl_platform_id * 1)() + check(cl.clGetPlatformIDs(1, platform_array, ctypes.byref(num_platforms))) + assert num_platforms.value > 0, "didn't get platform" + + device_array = (cl.cl_device_id * 1)() + num_devices = ctypes.c_uint32() + check(cl.clGetDeviceIDs(platform_array[0], CL_DEVICE_TYPE_DEFAULT, 1, device_array, ctypes.byref(num_devices))) + assert num_devices.value > 0, "didn't get device" + + status = ctypes.c_int32() + context = cl.clCreateContext(None, 1, device_array[0], ctypes.cast(None, cl.clCreateContext.argtypes[3]), None, ctypes.byref(status)) + check(status.value) + assert context is not None + + def test_malloc(self): + #cl.clCreateBuffer() + pass + +if __name__ == '__main__': + unittest.main()