From c7bb6857a988cb1fdbfda3ec71c8e9a51fc073e1 Mon Sep 17 00:00:00 2001 From: Valentin Churavy Date: Tue, 12 Aug 2014 17:49:03 +0200 Subject: [PATCH 1/7] split the api into seperate files --- src/api.jl | 298 +------------------------------------------ src/api/opencl_10.jl | 184 ++++++++++++++++++++++++++ src/api/opencl_11.jl | 61 +++++++++ src/api/opencl_12.jl | 64 ++++++++++ 4 files changed, 312 insertions(+), 295 deletions(-) create mode 100644 src/api/opencl_10.jl create mode 100644 src/api/opencl_11.jl create mode 100644 src/api/opencl_12.jl diff --git a/src/api.jl b/src/api.jl index b13c0387..45eb3739 100644 --- a/src/api.jl +++ b/src/api.jl @@ -43,303 +43,11 @@ macro ocl_func_1_2(func, ret_type, arg_types) end end -macro ocl_deprecate(func, ret_type, arg_types) - quote - @ocl_func($func, $ret_type, $arg_types) - end -end - typealias CL_callback Ptr{Void} typealias CL_user_data Any -#=== platform apis ===# -@ocl_func_1_0(clGetPlatformIDs, CL_int, - (CL_uint, Ptr{CL_platform_id}, Ptr{CL_uint})) - -@ocl_func_1_0(clGetPlatformInfo, - CL_int, (CL_platform_id, CL_platform_info, Csize_t, Ptr{Void}, Ptr{Csize_t})) - -#=== device apis ===# -@ocl_func_1_0(clGetDeviceIDs, CL_int, - (CL_platform_id, CL_device_type, CL_uint, Ptr{CL_device_id}, Ptr{CL_uint})) - -@ocl_func_1_0(clGetDeviceInfo, CL_int, - (CL_device_id, CL_device_info, Csize_t, Ptr{Void}, Ptr{Csize_t})) - -@ocl_func_1_2(clCreateSubDevices, CL_int, - (CL_device_id, CL_device_partition_property, CL_uint, Ptr{CL_device_id}, Ptr{CL_uint})) - -@ocl_func_1_2(clRetainDevice, CL_int, (CL_device_id,)) - -@ocl_func_1_2(clReleaseDevice, CL_int, (CL_device_id,)) - -#=== context apis ===# -#TODO: pass user data as Any type -@ocl_func_1_0(clCreateContext, CL_context, - (Ptr{CL_context_properties}, CL_uint, Ptr{CL_device_id}, CL_callback, CL_user_data, Ptr{CL_int})) - -@ocl_func_1_0(clCreateContextFromType, CL_context, - (Ptr{CL_context_properties}, CL_device_type, CL_callback, CL_user_data, Ptr{CL_int})) - -@ocl_func_1_0(clRetainContext, CL_int, (CL_context,)) - -@ocl_func_1_0(clReleaseContext, CL_int, (CL_context,)) - -@ocl_func_1_0(clGetContextInfo, CL_int, - (CL_context, CL_context_info, Csize_t, Ptr{Void}, Ptr{Csize_t})) - -#=== command queue apis ===# -@ocl_func_1_0(clCreateCommandQueue, CL_command_queue, - (CL_context, CL_device_id, CL_command_queue_properties, Ptr{CL_int})) - -@ocl_func_1_0(clRetainCommandQueue, CL_int, (CL_command_queue,)) - -@ocl_func_1_0(clReleaseCommandQueue, CL_int, (CL_command_queue,)) - -@ocl_func_1_0(clGetCommandQueueInfo, CL_int, - (CL_command_queue, CL_command_queue_info, Csize_t, Ptr{Void}, Ptr{Csize_t})) - -#=== memory object apis ===# -@ocl_func_1_0(clCreateBuffer, CL_mem, - (CL_context, CL_mem_flags, Csize_t, Ptr{Void}, Ptr{CL_int})) - -@ocl_func_1_1(clCreateSubBuffer, CL_mem, - (CL_mem, CL_mem_flags, CL_buffer_create_type, Ptr{Void}, Ptr{CL_int})) - -@ocl_func_1_2(clCreateImage, CL_mem, - (CL_context, CL_mem_flags, CL_image_format, CL_image_desc, Ptr{Void}, Ptr{CL_int})) - -@ocl_func_1_0(clRetainMemObject, CL_int, (CL_mem,)) - -@ocl_func_1_0(clReleaseMemObject, CL_int, (CL_mem,)) - -@ocl_func_1_0(clGetSupportedImageFormats, CL_int, - (CL_context, CL_mem_flags, CL_mem_object_type, CL_uint, Ptr{CL_image_format}, Ptr{CL_uint})) - -@ocl_func_1_0(clGetMemObjectInfo, CL_mem, - (CL_mem, CL_mem_info, Csize_t, Ptr{Void}, Ptr{Csize_t})) - -@ocl_func_1_0(clGetImageInfo, CL_mem, - (CL_mem, CL_image_info, Csize_t, Ptr{Void}, Ptr{Csize_t})) - -@ocl_func_1_1(clSetMemObjectDestructorCallback, CL_int, - (CL_mem, CL_callback, Ptr{Void})) - -#=== sampler apis ===# -@ocl_func_1_0(clCreateSampler, CL_sampler, - (CL_context, CL_bool, CL_addressing_mode, CL_filter_mode, Ptr{CL_int})) - -@ocl_func_1_0(clRetainSampler, CL_int, (CL_sampler,)) - -@ocl_func_1_0(clReleaseSampler, CL_int, (CL_sampler,)) - -@ocl_func_1_0(clGetSamplerInfo, CL_int, - (CL_sampler, CL_sampler_info, Csize_t, Ptr{Void}, Ptr{Csize_t})) - -#=== program object apis ===# -@ocl_func_1_0(clCreateProgramWithSource, CL_program, - (CL_context, CL_uint, Ptr{Ptr{Cchar}}, Ptr{Csize_t}, Ptr{CL_int})) - -@ocl_func_1_0(clCreateProgramWithBinary, CL_program, - (CL_context, CL_uint, Ptr{CL_device_id}, Ptr{Csize_t}, - Ptr{Ptr{Cuchar}}, Ptr{CL_int}, Ptr{CL_int})) - -@ocl_func_1_2(clCreateProgramWithBuiltInKernels, CL_program, - (CL_context, CL_uint, Ptr{CL_device_id}, Ptr{Cchar}, Ptr{CL_int})) - -@ocl_func_1_0(clRetainProgram, CL_int, (CL_program,)) - -@ocl_func_1_0(clReleaseProgram, CL_int, (CL_program,)) - -@ocl_func_1_0(clBuildProgram, CL_int, - (CL_program, CL_uint, Ptr{CL_device_id}, Ptr{Cchar}, CL_callback, Ptr{Void})) - -@ocl_func_1_2(clCompileProgram, CL_int, - (CL_program, CL_uint, Ptr{CL_device_id}, Ptr{CL_device_id}, Ptr{Cchar}, - CL_uint, Ptr{CL_program}, Ptr{Ptr{Char}}, CL_callback, Ptr{Void})) - -@ocl_func_1_2(clLinkProgram, CL_program, - (CL_context, CL_uint, Ptr{CL_device_id}, Ptr{Cchar}, CL_uint, - CL_callback, Ptr{Void}, Ptr{CL_int})) - -@ocl_func_1_2(clUnloadPlatformCompiler, CL_int, (CL_platform_id,)) - -@ocl_func_1_1(clGetProgramInfo, CL_int, - (CL_program, CL_program_info, Csize_t, Ptr{Void}, Ptr{Csize_t})) - -@ocl_func_1_0(clGetProgramBuildInfo, CL_int, - (CL_program, CL_device_id, CL_program_build_info, Csize_t, Ptr{Void}, Ptr{Csize_t})) - -#=== kernel object apis ===# -@ocl_func_1_0(clCreateKernel, CL_kernel, - (CL_program, Ptr{Cchar}, Ptr{CL_int})) - -@ocl_func_1_0(clCreateKernelsInProgram, CL_int, - (CL_program, CL_uint, Ptr{CL_kernel}, Ptr{CL_uint})) - -@ocl_func_1_0(clRetainKernel, CL_int, (CL_kernel,)) - -@ocl_func_1_0(clReleaseKernel, CL_int, (CL_kernel,)) - -@ocl_func_1_0(clSetKernelArg, CL_int, - (CL_kernel, CL_uint, Csize_t, Ptr{Void})) - -@ocl_func_1_0(clGetKernelInfo, CL_int, - (CL_kernel, CL_kernel_info, Csize_t, Ptr{Void}, Ptr{Csize_t})) - -@ocl_func_1_2(clGetKernelArgInfo, CL_int, - (CL_kernel, CL_uint, CL_kernel_arg_info, Csize_t, Ptr{Void}, Ptr{Csize_t})) - -@ocl_func_1_0(clGetKernelWorkGroupInfo, CL_int, - (CL_kernel, CL_device_id, CL_kernel_work_group_info, Csize_t, Ptr{Void}, Ptr{Csize_t})) - -#=== event object apis ===# -@ocl_func_1_0(clWaitForEvents, CL_int, - (CL_uint, Ptr{CL_event_info})) - -@ocl_func_1_0(clGetEventInfo, CL_int, - (CL_event, CL_event_info, Csize_t, Ptr{Void}, Ptr{Csize_t})) - -@ocl_func_1_1(clCreateUserEvent, CL_event, - (CL_context, Ptr{CL_int})) - -@ocl_func_1_0(clRetainEvent, CL_int, (CL_event,)) - -@ocl_func_1_0(clReleaseEvent, CL_int, (CL_event,)) - -@ocl_func_1_1(clSetUserEventStatus, CL_int, (CL_event, CL_int)) - -@ocl_func_1_1(clSetEventCallback, CL_int, - (CL_event, CL_int, CL_callback, CL_user_data)) - -#=== profiling apis ===# -@ocl_func_1_0(clGetEventProfilingInfo, CL_int, - (CL_event, CL_profiling_info, Csize_t, Ptr{Void}, Ptr{Csize_t})) - -#=== flush and finish apis ===# -@ocl_func_1_0(clFlush, CL_int, (CL_command_queue,)) - -@ocl_func_1_0(clFinish, CL_int, (CL_command_queue,)) - -#=== enqueued commands apis ===# -@ocl_func_1_0(clEnqueueReadBuffer, CL_int, - (CL_command_queue, CL_mem, CL_bool, Csize_t, Csize_t, Ptr{Void}, - CL_uint, Ptr{CL_event}, Ptr{CL_event})) - -@ocl_func_1_1(clEnqueueReadBufferRect, CL_int, - (CL_command_queue, CL_mem, CL_bool, - Ptr{Csize_t}, Ptr{Csize_t}, Ptr{Csize_t}, - Csize_t, Csize_t, Csize_t, Csize_t, - Ptr{Void}, CL_uint, Ptr{CL_event}, Ptr{CL_event})) - -@ocl_func_1_0(clEnqueueWriteBuffer, CL_int, - (CL_command_queue, CL_mem, CL_bool, - Csize_t, Csize_t, Ptr{Void}, CL_uint, - Ptr{CL_event}, Ptr{CL_event})) - -@ocl_func_1_1(clEnqueueWriteBufferRect, CL_int, - (CL_command_queue, CL_mem, CL_bool, - Ptr{Csize_t}, Ptr{Csize_t}, Ptr{Csize_t}, - Csize_t, Csize_t, Csize_t, Csize_t, - Ptr{Void}, CL_uint, Ptr{CL_event}, Ptr{CL_event})) - -@ocl_func_1_2(clEnqueueFillBuffer, CL_int, - (CL_command_queue, CL_mem, Ptr{Void}, Csize_t, Csize_t, Csize_t, - CL_uint, Ptr{CL_event}, Ptr{CL_event})) - -@ocl_func_1_0(clEnqueueCopyBuffer, CL_int, - (CL_command_queue, CL_mem, CL_mem, - Csize_t, Csize_t, Csize_t, CL_uint, Ptr{CL_event}, Ptr{CL_event})) - -@ocl_func_1_1(clEnqueueCopyBufferRect, CL_int, - (CL_command_queue, CL_mem, CL_mem, - Ptr{Csize_t}, Ptr{Csize_t}, Ptr{Csize_t}, - Csize_t, Csize_t, Csize_t, Csize_t, - CL_uint, Ptr{CL_event}, Ptr{CL_event})) - -@ocl_func_1_0(clEnqueueReadImage, CL_int, - (CL_command_queue, CL_mem, CL_bool, - Ptr{Csize_t}, Ptr{Csize_t}, Csize_t, Csize_t, - Ptr{Void}, CL_uint, Ptr{CL_event}, Ptr{CL_event})) - -@ocl_func_1_0(clEnqueueWriteImage, CL_int, - (CL_command_queue, CL_mem, CL_bool, Ptr{Csize_t}, Ptr{Csize_t}, - Csize_t, Csize_t, Ptr{Void}, CL_uint, Ptr{CL_event}, Ptr{CL_event})) - -@ocl_func_1_2(clEnqueueFillImage, CL_int, - (CL_command_queue, CL_mem, Ptr{Void}, Ptr{Csize_t}, Ptr{Csize_t}, - CL_uint, Ptr{CL_event}, Ptr{CL_event})) - -@ocl_func_1_0(clEnqueueCopyImage, CL_int, - (CL_command_queue, CL_mem, CL_mem, Ptr{Csize_t}, Ptr{Csize_t}, Ptr{Csize_t}, - CL_uint, Ptr{CL_event}, Ptr{CL_event})) - -@ocl_func_1_0(clEnqueueCopyImageToBuffer, CL_int, - (CL_command_queue, CL_mem, CL_mem, Ptr{Csize_t}, Ptr{Csize_t}, - Csize_t, CL_uint, Ptr{CL_event}, Ptr{CL_event})) - -@ocl_func_1_0(clEnqueueCopyBufferToImage, CL_int, - (CL_command_queue, CL_mem, CL_mem, Csize_t, Ptr{Csize_t}, Ptr{Csize_t}, - CL_uint, Ptr{CL_event}, Ptr{CL_event})) - -@ocl_func_1_0(clEnqueueMapBuffer, Ptr{Void}, - (CL_command_queue, CL_mem, CL_bool, CL_map_flags, Csize_t, Csize_t, - CL_uint, Ptr{CL_event}, Ptr{CL_event}, Ptr{CL_int})) - -@ocl_func_1_0(clEnqueueMapImage, Ptr{Void}, - (CL_command_queue, CL_mem, CL_bool, CL_map_flags, - Ptr{Csize_t}, Ptr{Csize_t}, Ptr{Csize_t}, Ptr{Csize_t}, - CL_uint, Ptr{CL_event}, Ptr{CL_event}, Ptr{CL_int})) - -@ocl_func_1_0(clEnqueueUnmapMemObject, CL_int, - (CL_command_queue, CL_mem, Ptr{Void}, CL_uint, Ptr{CL_event}, Ptr{CL_event})) - -@ocl_func_1_2(clEnqueueMigrateMemObjects, CL_int, - (CL_command_queue, CL_uint, Ptr{CL_mem}, CL_mem_migration_flags, - CL_uint, Ptr{CL_event}, Ptr{CL_event})) - -@ocl_func_1_0(clEnqueueNDRangeKernel, CL_int, - (CL_command_queue, CL_kernel, CL_uint, - Ptr{Csize_t}, Ptr{Csize_t}, Ptr{Csize_t}, - CL_uint, Ptr{CL_event}, Ptr{CL_event})) - -@ocl_func_1_0(clEnqueueTask, CL_int, - (CL_command_queue, CL_kernel, CL_uint, Ptr{CL_event}, Ptr{CL_event})) - -@ocl_func_1_0(clEnqueueNativeKernel, CL_int, - (CL_command_queue, Ptr{Void}, Csize_t, CL_uint, - Ptr{CL_mem}, Ptr{Ptr{Void}}, CL_uint, Ptr{CL_event}, Ptr{CL_event})) - -@ocl_func_1_2(clEnqueueMarkerWithWaitList, CL_int, - (CL_command_queue, CL_uint, Ptr{CL_event}, Ptr{CL_event})) - -@ocl_func_1_2(clEnqueueBarrierWithWaitList, CL_int, - (CL_command_queue, CL_uint, Ptr{CL_event}, Ptr{CL_event})) - -#=== extension function access ===# -@ocl_func_1_2(clGetExtensionFunctionAddressForPlatform, Ptr{Void}, - (CL_platform_id, Ptr{Cchar})) - -#=== deprecated functions ===# -@ocl_deprecate(clCreateImage2D, CL_mem, - (CL_context, CL_mem_flags, Ptr{CL_image_format}, Csize_t, Csize_t, Csize_t, - Ptr{Void}, Ptr{CL_int})) - -@ocl_deprecate(clCreateImage3D, CL_mem, - (CL_context, CL_mem_flags, Ptr{CL_image_format}, Csize_t, Csize_t, Csize_t, - Csize_t, Ptr{Void}, Ptr{CL_int})) - -@ocl_deprecate(clEnqueueMarker, CL_int, - (CL_command_queue, Ptr{CL_event})) - -@ocl_deprecate(clEnqueueWaitForEvents, CL_int, - (CL_command_queue, CL_uint, Ptr{CL_event})) - -@ocl_deprecate(clEnqueueBarrier, CL_int, - (CL_command_queue,)) - -@ocl_deprecate(clUnloadCompiler, CL_int, ()) - -@ocl_deprecate(clGetExtensionFunctionAddress, Ptr{Void}, (Ptr{Cchar},)) +include("api/opencl_10.jl") +include("api/opencl_11.jl") +include("api/opencl_12.jl") end diff --git a/src/api/opencl_10.jl b/src/api/opencl_10.jl new file mode 100644 index 00000000..11dc33c2 --- /dev/null +++ b/src/api/opencl_10.jl @@ -0,0 +1,184 @@ +#=== platform apis ===# +@ocl_func_1_0(clGetPlatformIDs, CL_int, + (CL_uint, Ptr{CL_platform_id}, Ptr{CL_uint})) + +@ocl_func_1_0(clGetPlatformInfo, + CL_int, (CL_platform_id, CL_platform_info, Csize_t, Ptr{Void}, Ptr{Csize_t})) + +#=== device apis ===# +@ocl_func_1_0(clGetDeviceIDs, CL_int, + (CL_platform_id, CL_device_type, CL_uint, Ptr{CL_device_id}, Ptr{CL_uint})) + +@ocl_func_1_0(clGetDeviceInfo, CL_int, + (CL_device_id, CL_device_info, Csize_t, Ptr{Void}, Ptr{Csize_t})) + +#=== context apis ===# +#TODO: pass user data as Any type +@ocl_func_1_0(clCreateContext, CL_context, + (Ptr{CL_context_properties}, CL_uint, Ptr{CL_device_id}, CL_callback, CL_user_data, Ptr{CL_int})) + +@ocl_func_1_0(clCreateContextFromType, CL_context, + (Ptr{CL_context_properties}, CL_device_type, CL_callback, CL_user_data, Ptr{CL_int})) + +@ocl_func_1_0(clRetainContext, CL_int, (CL_context,)) + +@ocl_func_1_0(clReleaseContext, CL_int, (CL_context,)) + +@ocl_func_1_0(clGetContextInfo, CL_int, + (CL_context, CL_context_info, Csize_t, Ptr{Void}, Ptr{Csize_t})) + +#=== command queue apis ===# +@ocl_func_1_0(clCreateCommandQueue, CL_command_queue, + (CL_context, CL_device_id, CL_command_queue_properties, Ptr{CL_int})) + +@ocl_func_1_0(clRetainCommandQueue, CL_int, (CL_command_queue,)) + +@ocl_func_1_0(clReleaseCommandQueue, CL_int, (CL_command_queue,)) + +@ocl_func_1_0(clGetCommandQueueInfo, CL_int, + (CL_command_queue, CL_command_queue_info, Csize_t, Ptr{Void}, Ptr{Csize_t})) + +#=== memory object apis ===# +@ocl_func_1_0(clCreateBuffer, CL_mem, + (CL_context, CL_mem_flags, Csize_t, Ptr{Void}, Ptr{CL_int})) + +@ocl_func_1_0(clRetainMemObject, CL_int, (CL_mem,)) + +@ocl_func_1_0(clReleaseMemObject, CL_int, (CL_mem,)) + +@ocl_func_1_0(clGetSupportedImageFormats, CL_int, + (CL_context, CL_mem_flags, CL_mem_object_type, CL_uint, Ptr{CL_image_format}, Ptr{CL_uint})) + +@ocl_func_1_0(clGetMemObjectInfo, CL_mem, + (CL_mem, CL_mem_info, Csize_t, Ptr{Void}, Ptr{Csize_t})) + +@ocl_func_1_0(clGetImageInfo, CL_mem, + (CL_mem, CL_image_info, Csize_t, Ptr{Void}, Ptr{Csize_t})) + +#=== sampler apis ===# +@ocl_func_1_0(clCreateSampler, CL_sampler, + (CL_context, CL_bool, CL_addressing_mode, CL_filter_mode, Ptr{CL_int})) + +@ocl_func_1_0(clRetainSampler, CL_int, (CL_sampler,)) + +@ocl_func_1_0(clReleaseSampler, CL_int, (CL_sampler,)) + +@ocl_func_1_0(clGetSamplerInfo, CL_int, + (CL_sampler, CL_sampler_info, Csize_t, Ptr{Void}, Ptr{Csize_t})) + +#=== program object apis ===# +@ocl_func_1_0(clCreateProgramWithSource, CL_program, + (CL_context, CL_uint, Ptr{Ptr{Cchar}}, Ptr{Csize_t}, Ptr{CL_int})) + +@ocl_func_1_0(clCreateProgramWithBinary, CL_program, + (CL_context, CL_uint, Ptr{CL_device_id}, Ptr{Csize_t}, + Ptr{Ptr{Cuchar}}, Ptr{CL_int}, Ptr{CL_int})) + +@ocl_func_1_0(clRetainProgram, CL_int, (CL_program,)) + +@ocl_func_1_0(clReleaseProgram, CL_int, (CL_program,)) + +@ocl_func_1_0(clBuildProgram, CL_int, + (CL_program, CL_uint, Ptr{CL_device_id}, Ptr{Cchar}, CL_callback, Ptr{Void})) + +@ocl_func_1_0(clGetProgramBuildInfo, CL_int, + (CL_program, CL_device_id, CL_program_build_info, Csize_t, Ptr{Void}, Ptr{Csize_t})) + +#=== kernel object apis ===# +@ocl_func_1_0(clCreateKernel, CL_kernel, + (CL_program, Ptr{Cchar}, Ptr{CL_int})) + +@ocl_func_1_0(clCreateKernelsInProgram, CL_int, + (CL_program, CL_uint, Ptr{CL_kernel}, Ptr{CL_uint})) + +@ocl_func_1_0(clRetainKernel, CL_int, (CL_kernel,)) + +@ocl_func_1_0(clReleaseKernel, CL_int, (CL_kernel,)) + +@ocl_func_1_0(clSetKernelArg, CL_int, + (CL_kernel, CL_uint, Csize_t, Ptr{Void})) + +@ocl_func_1_0(clGetKernelInfo, CL_int, + (CL_kernel, CL_kernel_info, Csize_t, Ptr{Void}, Ptr{Csize_t})) + +@ocl_func_1_0(clGetKernelWorkGroupInfo, CL_int, + (CL_kernel, CL_device_id, CL_kernel_work_group_info, Csize_t, Ptr{Void}, Ptr{Csize_t})) + +#=== event object apis ===# +@ocl_func_1_0(clWaitForEvents, CL_int, + (CL_uint, Ptr{CL_event_info})) + +@ocl_func_1_0(clGetEventInfo, CL_int, + (CL_event, CL_event_info, Csize_t, Ptr{Void}, Ptr{Csize_t})) + +@ocl_func_1_0(clRetainEvent, CL_int, (CL_event,)) + +@ocl_func_1_0(clReleaseEvent, CL_int, (CL_event,)) + +#=== profiling apis ===# +@ocl_func_1_0(clGetEventProfilingInfo, CL_int, + (CL_event, CL_profiling_info, Csize_t, Ptr{Void}, Ptr{Csize_t})) + +#=== flush and finish apis ===# +@ocl_func_1_0(clFlush, CL_int, (CL_command_queue,)) + +@ocl_func_1_0(clFinish, CL_int, (CL_command_queue,)) + +#=== enqueued commands apis ===# +@ocl_func_1_0(clEnqueueReadBuffer, CL_int, + (CL_command_queue, CL_mem, CL_bool, Csize_t, Csize_t, Ptr{Void}, + CL_uint, Ptr{CL_event}, Ptr{CL_event})) + +@ocl_func_1_0(clEnqueueWriteBuffer, CL_int, + (CL_command_queue, CL_mem, CL_bool, + Csize_t, Csize_t, Ptr{Void}, CL_uint, + Ptr{CL_event}, Ptr{CL_event})) + +@ocl_func_1_0(clEnqueueCopyBuffer, CL_int, + (CL_command_queue, CL_mem, CL_mem, + Csize_t, Csize_t, Csize_t, CL_uint, Ptr{CL_event}, Ptr{CL_event})) + +@ocl_func_1_0(clEnqueueReadImage, CL_int, + (CL_command_queue, CL_mem, CL_bool, + Ptr{Csize_t}, Ptr{Csize_t}, Csize_t, Csize_t, + Ptr{Void}, CL_uint, Ptr{CL_event}, Ptr{CL_event})) + +@ocl_func_1_0(clEnqueueWriteImage, CL_int, + (CL_command_queue, CL_mem, CL_bool, Ptr{Csize_t}, Ptr{Csize_t}, + Csize_t, Csize_t, Ptr{Void}, CL_uint, Ptr{CL_event}, Ptr{CL_event})) + +@ocl_func_1_0(clEnqueueCopyImage, CL_int, + (CL_command_queue, CL_mem, CL_mem, Ptr{Csize_t}, Ptr{Csize_t}, Ptr{Csize_t}, + CL_uint, Ptr{CL_event}, Ptr{CL_event})) + +@ocl_func_1_0(clEnqueueCopyImageToBuffer, CL_int, + (CL_command_queue, CL_mem, CL_mem, Ptr{Csize_t}, Ptr{Csize_t}, + Csize_t, CL_uint, Ptr{CL_event}, Ptr{CL_event})) + +@ocl_func_1_0(clEnqueueCopyBufferToImage, CL_int, + (CL_command_queue, CL_mem, CL_mem, Csize_t, Ptr{Csize_t}, Ptr{Csize_t}, + CL_uint, Ptr{CL_event}, Ptr{CL_event})) + +@ocl_func_1_0(clEnqueueMapBuffer, Ptr{Void}, + (CL_command_queue, CL_mem, CL_bool, CL_map_flags, Csize_t, Csize_t, + CL_uint, Ptr{CL_event}, Ptr{CL_event}, Ptr{CL_int})) + +@ocl_func_1_0(clEnqueueMapImage, Ptr{Void}, + (CL_command_queue, CL_mem, CL_bool, CL_map_flags, + Ptr{Csize_t}, Ptr{Csize_t}, Ptr{Csize_t}, Ptr{Csize_t}, + CL_uint, Ptr{CL_event}, Ptr{CL_event}, Ptr{CL_int})) + +@ocl_func_1_0(clEnqueueUnmapMemObject, CL_int, + (CL_command_queue, CL_mem, Ptr{Void}, CL_uint, Ptr{CL_event}, Ptr{CL_event})) + +@ocl_func_1_0(clEnqueueNDRangeKernel, CL_int, + (CL_command_queue, CL_kernel, CL_uint, + Ptr{Csize_t}, Ptr{Csize_t}, Ptr{Csize_t}, + CL_uint, Ptr{CL_event}, Ptr{CL_event})) + +@ocl_func_1_0(clEnqueueTask, CL_int, + (CL_command_queue, CL_kernel, CL_uint, Ptr{CL_event}, Ptr{CL_event})) + +@ocl_func_1_0(clEnqueueNativeKernel, CL_int, + (CL_command_queue, Ptr{Void}, Csize_t, CL_uint, + Ptr{CL_mem}, Ptr{Ptr{Void}}, CL_uint, Ptr{CL_event}, Ptr{CL_event})) \ No newline at end of file diff --git a/src/api/opencl_11.jl b/src/api/opencl_11.jl new file mode 100644 index 00000000..99f690cc --- /dev/null +++ b/src/api/opencl_11.jl @@ -0,0 +1,61 @@ +#=== memory object apis ===# +@ocl_func_1_1(clCreateSubBuffer, CL_mem, + (CL_mem, CL_mem_flags, CL_buffer_create_type, Ptr{Void}, Ptr{CL_int})) + +@ocl_func_1_1(clSetMemObjectDestructorCallback, CL_int, + (CL_mem, CL_callback, Ptr{Void})) + +#=== program object apis ===# +@ocl_func_1_1(clGetProgramInfo, CL_int, + (CL_program, CL_program_info, Csize_t, Ptr{Void}, Ptr{Csize_t})) + +#=== event object apis ===# +@ocl_func_1_1(clCreateUserEvent, CL_event, + (CL_context, Ptr{CL_int})) + +@ocl_func_1_1(clSetUserEventStatus, CL_int, (CL_event, CL_int)) + +@ocl_func_1_1(clSetEventCallback, CL_int, + (CL_event, CL_int, CL_callback, CL_user_data)) + +#=== enqueued commands apis ===# +@ocl_func_1_1(clEnqueueReadBufferRect, CL_int, + (CL_command_queue, CL_mem, CL_bool, + Ptr{Csize_t}, Ptr{Csize_t}, Ptr{Csize_t}, + Csize_t, Csize_t, Csize_t, Csize_t, + Ptr{Void}, CL_uint, Ptr{CL_event}, Ptr{CL_event})) + +@ocl_func_1_1(clEnqueueWriteBufferRect, CL_int, + (CL_command_queue, CL_mem, CL_bool, + Ptr{Csize_t}, Ptr{Csize_t}, Ptr{Csize_t}, + Csize_t, Csize_t, Csize_t, Csize_t, + Ptr{Void}, CL_uint, Ptr{CL_event}, Ptr{CL_event})) + +@ocl_func_1_1(clEnqueueCopyBufferRect, CL_int, + (CL_command_queue, CL_mem, CL_mem, + Ptr{Csize_t}, Ptr{Csize_t}, Ptr{Csize_t}, + Csize_t, Csize_t, Csize_t, Csize_t, + CL_uint, Ptr{CL_event}, Ptr{CL_event})) + +#=== extension function access ===# +@ocl_func_1_1(clGetExtensionFunctionAddress, Ptr{Void}, (Ptr{Cchar},)) + +#=== deprecated functions ===# +@ocl_func_1_1(clCreateImage2D, CL_mem, + (CL_context, CL_mem_flags, Ptr{CL_image_format}, Csize_t, Csize_t, Csize_t, + Ptr{Void}, Ptr{CL_int})) + +@ocl_func_1_1(clCreateImage3D, CL_mem, + (CL_context, CL_mem_flags, Ptr{CL_image_format}, Csize_t, Csize_t, Csize_t, + Csize_t, Ptr{Void}, Ptr{CL_int})) + +@ocl_func_1_1(clEnqueueMarker, CL_int, + (CL_command_queue, Ptr{CL_event})) + +@ocl_func_1_1(clEnqueueWaitForEvents, CL_int, + (CL_command_queue, CL_uint, Ptr{CL_event})) + +@ocl_func_1_1(clEnqueueBarrier, CL_int, + (CL_command_queue,)) + +@ocl_func_1_1(clUnloadCompiler, CL_int, ()) \ No newline at end of file diff --git a/src/api/opencl_12.jl b/src/api/opencl_12.jl new file mode 100644 index 00000000..eee3a347 --- /dev/null +++ b/src/api/opencl_12.jl @@ -0,0 +1,64 @@ +#=== device apis ===# +@ocl_func_1_2(clCreateSubDevices, CL_int, + (CL_device_id, CL_device_partition_property, CL_uint, Ptr{CL_device_id}, Ptr{CL_uint})) + +@ocl_func_1_2(clRetainDevice, CL_int, (CL_device_id,)) + +@ocl_func_1_2(clReleaseDevice, CL_int, (CL_device_id,)) + +#=== memory object apis ===# +@ocl_func_1_2(clCreateImage, CL_mem, + (CL_context, CL_mem_flags, CL_image_format, CL_image_desc, Ptr{Void}, Ptr{CL_int})) + +#=== program object apis ===# +@ocl_func_1_2(clCreateProgramWithBuiltInKernels, CL_program, + (CL_context, CL_uint, Ptr{CL_device_id}, Ptr{Cchar}, Ptr{CL_int})) + +@ocl_func_1_2(clCompileProgram, CL_int, + (CL_program, CL_uint, Ptr{CL_device_id}, Ptr{CL_device_id}, Ptr{Cchar}, + CL_uint, Ptr{CL_program}, Ptr{Ptr{Char}}, CL_callback, Ptr{Void})) + +@ocl_func_1_2(clLinkProgram, CL_program, + (CL_context, CL_uint, Ptr{CL_device_id}, Ptr{Cchar}, CL_uint, + CL_callback, Ptr{Void}, Ptr{CL_int})) + +@ocl_func_1_2(clUnloadPlatformCompiler, CL_int, (CL_platform_id,)) + +#=== kernel object apis ===# +@ocl_func_1_2(clGetKernelArgInfo, CL_int, + (CL_kernel, CL_uint, CL_kernel_arg_info, Csize_t, Ptr{Void}, Ptr{Csize_t})) + +#=== enqueued commands apis ===# +@ocl_func_1_2(clEnqueueFillBuffer, CL_int, + (CL_command_queue, CL_mem, Ptr{Void}, Csize_t, Csize_t, Csize_t, + CL_uint, Ptr{CL_event}, Ptr{CL_event})) + +@ocl_func_1_2(clEnqueueFillImage, CL_int, + (CL_command_queue, CL_mem, Ptr{Void}, Ptr{Csize_t}, Ptr{Csize_t}, + CL_uint, Ptr{CL_event}, Ptr{CL_event})) + +@ocl_func_1_2(clEnqueueMigrateMemObjects, CL_int, + (CL_command_queue, CL_uint, Ptr{CL_mem}, CL_mem_migration_flags, + CL_uint, Ptr{CL_event}, Ptr{CL_event})) + +@ocl_func_1_2(clEnqueueMarkerWithWaitList, CL_int, + (CL_command_queue, CL_uint, Ptr{CL_event}, Ptr{CL_event})) + +@ocl_func_1_2(clEnqueueBarrierWithWaitList, CL_int, + (CL_command_queue, CL_uint, Ptr{CL_event}, Ptr{CL_event})) + +#=== extension function access ===# +@ocl_func_1_2(clGetExtensionFunctionAddressForPlatform, Ptr{Void}, + (CL_platform_id, Ptr{Cchar})) + +#=== deprecation ===# + +@deprecate clGetExtensionFunctionAddress clGetExtensionFunctionAddressForPlatform + +@deprecate clCreateImage2D clCreateImage +@deprecate clCreateImage3D clCreateImage + +@deprecate clEnqueueMarker clEnqueueMarkerWithWaitList +@deprecate clEnqueueBarrier clEnqueueMarkerWithWaitList +@deprecate clEnqueueWaitForEvents clEnqueueMarkerWithWaitList +@deprecate clUnloadCompiler Nothing() \ No newline at end of file From 722b0413856e6b4657fca0f00234c455a2fed5c8 Mon Sep 17 00:00:00 2001 From: Valentin Churavy Date: Wed, 13 Aug 2014 08:55:31 +0200 Subject: [PATCH 2/7] deprecation not working --- src/api/opencl_12.jl | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/api/opencl_12.jl b/src/api/opencl_12.jl index eee3a347..7f27b89d 100644 --- a/src/api/opencl_12.jl +++ b/src/api/opencl_12.jl @@ -53,12 +53,12 @@ #=== deprecation ===# -@deprecate clGetExtensionFunctionAddress clGetExtensionFunctionAddressForPlatform +# @deprecate clGetExtensionFunctionAddress clGetExtensionFunctionAddressForPlatform -@deprecate clCreateImage2D clCreateImage -@deprecate clCreateImage3D clCreateImage +# @deprecate clCreateImage2D clCreateImage +# @deprecate clCreateImage3D clCreateImage -@deprecate clEnqueueMarker clEnqueueMarkerWithWaitList -@deprecate clEnqueueBarrier clEnqueueMarkerWithWaitList -@deprecate clEnqueueWaitForEvents clEnqueueMarkerWithWaitList -@deprecate clUnloadCompiler Nothing() \ No newline at end of file +# @deprecate clEnqueueMarker clEnqueueMarkerWithWaitList +# @deprecate clEnqueueBarrier clEnqueueMarkerWithWaitList +# @deprecate clEnqueueWaitForEvents clEnqueueMarkerWithWaitList +# @deprecate clUnloadCompiler Nothing() \ No newline at end of file From 7cfb52f88d6a8f3618558e913e74048b8ddf3c35 Mon Sep 17 00:00:00 2001 From: Valentin Churavy Date: Tue, 12 Aug 2014 19:19:11 +0200 Subject: [PATCH 3/7] only use one macro --- src/api.jl | 32 +++-------- src/api/opencl_10.jl | 134 +++++++++++++++++++++---------------------- src/api/opencl_11.jl | 42 +++++++------- src/api/opencl_12.jl | 36 ++++++------ 4 files changed, 113 insertions(+), 131 deletions(-) diff --git a/src/api.jl b/src/api.jl index 45eb3739..56dfd532 100644 --- a/src/api.jl +++ b/src/api.jl @@ -17,34 +17,16 @@ end macro ocl_func(func, ret_type, arg_types) local args_in = Symbol[symbol("arg$i::$T") for (i, T) in enumerate(arg_types.args)] - quote - $(esc(func))($(args_in...)) = ccall(($(string(func)), libopencl), - $ret_type, - $arg_types, - $(args_in...)) - end -end - -macro ocl_func_1_0(func, ret_type, arg_types) - quote - @ocl_func($func, $ret_type, $arg_types) - end -end - -macro ocl_func_1_1(func, ret_type, arg_types) - quote - @ocl_func($func, $ret_type, $arg_types) - end -end - -macro ocl_func_1_2(func, ret_type, arg_types) - quote - @ocl_func($func, $ret_type, $arg_types) - end + esc(quote + $func($(args_in...)) = ccall(($(string(func)), libopencl), + $ret_type, + $arg_types, + $(args_in...)) + end) end typealias CL_callback Ptr{Void} -typealias CL_user_data Any +typealias CL_user_data Any include("api/opencl_10.jl") include("api/opencl_11.jl") diff --git a/src/api/opencl_10.jl b/src/api/opencl_10.jl index 11dc33c2..f6c82a3b 100644 --- a/src/api/opencl_10.jl +++ b/src/api/opencl_10.jl @@ -1,184 +1,184 @@ #=== platform apis ===# -@ocl_func_1_0(clGetPlatformIDs, CL_int, +@ocl_func(clGetPlatformIDs, CL_int, (CL_uint, Ptr{CL_platform_id}, Ptr{CL_uint})) -@ocl_func_1_0(clGetPlatformInfo, +@ocl_func(clGetPlatformInfo, CL_int, (CL_platform_id, CL_platform_info, Csize_t, Ptr{Void}, Ptr{Csize_t})) #=== device apis ===# -@ocl_func_1_0(clGetDeviceIDs, CL_int, +@ocl_func(clGetDeviceIDs, CL_int, (CL_platform_id, CL_device_type, CL_uint, Ptr{CL_device_id}, Ptr{CL_uint})) -@ocl_func_1_0(clGetDeviceInfo, CL_int, +@ocl_func(clGetDeviceInfo, CL_int, (CL_device_id, CL_device_info, Csize_t, Ptr{Void}, Ptr{Csize_t})) #=== context apis ===# -#TODO: pass user data as Any type -@ocl_func_1_0(clCreateContext, CL_context, +#TODO: pass user data as Any type +@ocl_func(clCreateContext, CL_context, (Ptr{CL_context_properties}, CL_uint, Ptr{CL_device_id}, CL_callback, CL_user_data, Ptr{CL_int})) -@ocl_func_1_0(clCreateContextFromType, CL_context, +@ocl_func(clCreateContextFromType, CL_context, (Ptr{CL_context_properties}, CL_device_type, CL_callback, CL_user_data, Ptr{CL_int})) -@ocl_func_1_0(clRetainContext, CL_int, (CL_context,)) +@ocl_func(clRetainContext, CL_int, (CL_context,)) -@ocl_func_1_0(clReleaseContext, CL_int, (CL_context,)) +@ocl_func(clReleaseContext, CL_int, (CL_context,)) -@ocl_func_1_0(clGetContextInfo, CL_int, +@ocl_func(clGetContextInfo, CL_int, (CL_context, CL_context_info, Csize_t, Ptr{Void}, Ptr{Csize_t})) #=== command queue apis ===# -@ocl_func_1_0(clCreateCommandQueue, CL_command_queue, +@ocl_func(clCreateCommandQueue, CL_command_queue, (CL_context, CL_device_id, CL_command_queue_properties, Ptr{CL_int})) -@ocl_func_1_0(clRetainCommandQueue, CL_int, (CL_command_queue,)) +@ocl_func(clRetainCommandQueue, CL_int, (CL_command_queue,)) -@ocl_func_1_0(clReleaseCommandQueue, CL_int, (CL_command_queue,)) +@ocl_func(clReleaseCommandQueue, CL_int, (CL_command_queue,)) -@ocl_func_1_0(clGetCommandQueueInfo, CL_int, +@ocl_func(clGetCommandQueueInfo, CL_int, (CL_command_queue, CL_command_queue_info, Csize_t, Ptr{Void}, Ptr{Csize_t})) #=== memory object apis ===# -@ocl_func_1_0(clCreateBuffer, CL_mem, +@ocl_func(clCreateBuffer, CL_mem, (CL_context, CL_mem_flags, Csize_t, Ptr{Void}, Ptr{CL_int})) -@ocl_func_1_0(clRetainMemObject, CL_int, (CL_mem,)) +@ocl_func(clRetainMemObject, CL_int, (CL_mem,)) -@ocl_func_1_0(clReleaseMemObject, CL_int, (CL_mem,)) +@ocl_func(clReleaseMemObject, CL_int, (CL_mem,)) -@ocl_func_1_0(clGetSupportedImageFormats, CL_int, +@ocl_func(clGetSupportedImageFormats, CL_int, (CL_context, CL_mem_flags, CL_mem_object_type, CL_uint, Ptr{CL_image_format}, Ptr{CL_uint})) -@ocl_func_1_0(clGetMemObjectInfo, CL_mem, +@ocl_func(clGetMemObjectInfo, CL_mem, (CL_mem, CL_mem_info, Csize_t, Ptr{Void}, Ptr{Csize_t})) -@ocl_func_1_0(clGetImageInfo, CL_mem, +@ocl_func(clGetImageInfo, CL_mem, (CL_mem, CL_image_info, Csize_t, Ptr{Void}, Ptr{Csize_t})) - + #=== sampler apis ===# -@ocl_func_1_0(clCreateSampler, CL_sampler, +@ocl_func(clCreateSampler, CL_sampler, (CL_context, CL_bool, CL_addressing_mode, CL_filter_mode, Ptr{CL_int})) -@ocl_func_1_0(clRetainSampler, CL_int, (CL_sampler,)) +@ocl_func(clRetainSampler, CL_int, (CL_sampler,)) -@ocl_func_1_0(clReleaseSampler, CL_int, (CL_sampler,)) +@ocl_func(clReleaseSampler, CL_int, (CL_sampler,)) -@ocl_func_1_0(clGetSamplerInfo, CL_int, +@ocl_func(clGetSamplerInfo, CL_int, (CL_sampler, CL_sampler_info, Csize_t, Ptr{Void}, Ptr{Csize_t})) #=== program object apis ===# -@ocl_func_1_0(clCreateProgramWithSource, CL_program, +@ocl_func(clCreateProgramWithSource, CL_program, (CL_context, CL_uint, Ptr{Ptr{Cchar}}, Ptr{Csize_t}, Ptr{CL_int})) -@ocl_func_1_0(clCreateProgramWithBinary, CL_program, - (CL_context, CL_uint, Ptr{CL_device_id}, Ptr{Csize_t}, +@ocl_func(clCreateProgramWithBinary, CL_program, + (CL_context, CL_uint, Ptr{CL_device_id}, Ptr{Csize_t}, Ptr{Ptr{Cuchar}}, Ptr{CL_int}, Ptr{CL_int})) -@ocl_func_1_0(clRetainProgram, CL_int, (CL_program,)) +@ocl_func(clRetainProgram, CL_int, (CL_program,)) -@ocl_func_1_0(clReleaseProgram, CL_int, (CL_program,)) +@ocl_func(clReleaseProgram, CL_int, (CL_program,)) -@ocl_func_1_0(clBuildProgram, CL_int, +@ocl_func(clBuildProgram, CL_int, (CL_program, CL_uint, Ptr{CL_device_id}, Ptr{Cchar}, CL_callback, Ptr{Void})) -@ocl_func_1_0(clGetProgramBuildInfo, CL_int, +@ocl_func(clGetProgramBuildInfo, CL_int, (CL_program, CL_device_id, CL_program_build_info, Csize_t, Ptr{Void}, Ptr{Csize_t})) #=== kernel object apis ===# -@ocl_func_1_0(clCreateKernel, CL_kernel, +@ocl_func(clCreateKernel, CL_kernel, (CL_program, Ptr{Cchar}, Ptr{CL_int})) -@ocl_func_1_0(clCreateKernelsInProgram, CL_int, +@ocl_func(clCreateKernelsInProgram, CL_int, (CL_program, CL_uint, Ptr{CL_kernel}, Ptr{CL_uint})) -@ocl_func_1_0(clRetainKernel, CL_int, (CL_kernel,)) +@ocl_func(clRetainKernel, CL_int, (CL_kernel,)) -@ocl_func_1_0(clReleaseKernel, CL_int, (CL_kernel,)) +@ocl_func(clReleaseKernel, CL_int, (CL_kernel,)) -@ocl_func_1_0(clSetKernelArg, CL_int, +@ocl_func(clSetKernelArg, CL_int, (CL_kernel, CL_uint, Csize_t, Ptr{Void})) -@ocl_func_1_0(clGetKernelInfo, CL_int, +@ocl_func(clGetKernelInfo, CL_int, (CL_kernel, CL_kernel_info, Csize_t, Ptr{Void}, Ptr{Csize_t})) -@ocl_func_1_0(clGetKernelWorkGroupInfo, CL_int, +@ocl_func(clGetKernelWorkGroupInfo, CL_int, (CL_kernel, CL_device_id, CL_kernel_work_group_info, Csize_t, Ptr{Void}, Ptr{Csize_t})) #=== event object apis ===# -@ocl_func_1_0(clWaitForEvents, CL_int, +@ocl_func(clWaitForEvents, CL_int, (CL_uint, Ptr{CL_event_info})) -@ocl_func_1_0(clGetEventInfo, CL_int, +@ocl_func(clGetEventInfo, CL_int, (CL_event, CL_event_info, Csize_t, Ptr{Void}, Ptr{Csize_t})) -@ocl_func_1_0(clRetainEvent, CL_int, (CL_event,)) +@ocl_func(clRetainEvent, CL_int, (CL_event,)) -@ocl_func_1_0(clReleaseEvent, CL_int, (CL_event,)) +@ocl_func(clReleaseEvent, CL_int, (CL_event,)) #=== profiling apis ===# -@ocl_func_1_0(clGetEventProfilingInfo, CL_int, +@ocl_func(clGetEventProfilingInfo, CL_int, (CL_event, CL_profiling_info, Csize_t, Ptr{Void}, Ptr{Csize_t})) #=== flush and finish apis ===# -@ocl_func_1_0(clFlush, CL_int, (CL_command_queue,)) +@ocl_func(clFlush, CL_int, (CL_command_queue,)) -@ocl_func_1_0(clFinish, CL_int, (CL_command_queue,)) +@ocl_func(clFinish, CL_int, (CL_command_queue,)) #=== enqueued commands apis ===# -@ocl_func_1_0(clEnqueueReadBuffer, CL_int, +@ocl_func(clEnqueueReadBuffer, CL_int, (CL_command_queue, CL_mem, CL_bool, Csize_t, Csize_t, Ptr{Void}, CL_uint, Ptr{CL_event}, Ptr{CL_event})) -@ocl_func_1_0(clEnqueueWriteBuffer, CL_int, - (CL_command_queue, CL_mem, CL_bool, - Csize_t, Csize_t, Ptr{Void}, CL_uint, +@ocl_func(clEnqueueWriteBuffer, CL_int, + (CL_command_queue, CL_mem, CL_bool, + Csize_t, Csize_t, Ptr{Void}, CL_uint, Ptr{CL_event}, Ptr{CL_event})) -@ocl_func_1_0(clEnqueueCopyBuffer, CL_int, +@ocl_func(clEnqueueCopyBuffer, CL_int, (CL_command_queue, CL_mem, CL_mem, Csize_t, Csize_t, Csize_t, CL_uint, Ptr{CL_event}, Ptr{CL_event})) -@ocl_func_1_0(clEnqueueReadImage, CL_int, +@ocl_func(clEnqueueReadImage, CL_int, (CL_command_queue, CL_mem, CL_bool, Ptr{Csize_t}, Ptr{Csize_t}, Csize_t, Csize_t, Ptr{Void}, CL_uint, Ptr{CL_event}, Ptr{CL_event})) -@ocl_func_1_0(clEnqueueWriteImage, CL_int, +@ocl_func(clEnqueueWriteImage, CL_int, (CL_command_queue, CL_mem, CL_bool, Ptr{Csize_t}, Ptr{Csize_t}, Csize_t, Csize_t, Ptr{Void}, CL_uint, Ptr{CL_event}, Ptr{CL_event})) -@ocl_func_1_0(clEnqueueCopyImage, CL_int, +@ocl_func(clEnqueueCopyImage, CL_int, (CL_command_queue, CL_mem, CL_mem, Ptr{Csize_t}, Ptr{Csize_t}, Ptr{Csize_t}, CL_uint, Ptr{CL_event}, Ptr{CL_event})) -@ocl_func_1_0(clEnqueueCopyImageToBuffer, CL_int, - (CL_command_queue, CL_mem, CL_mem, Ptr{Csize_t}, Ptr{Csize_t}, +@ocl_func(clEnqueueCopyImageToBuffer, CL_int, + (CL_command_queue, CL_mem, CL_mem, Ptr{Csize_t}, Ptr{Csize_t}, Csize_t, CL_uint, Ptr{CL_event}, Ptr{CL_event})) -@ocl_func_1_0(clEnqueueCopyBufferToImage, CL_int, - (CL_command_queue, CL_mem, CL_mem, Csize_t, Ptr{Csize_t}, Ptr{Csize_t}, +@ocl_func(clEnqueueCopyBufferToImage, CL_int, + (CL_command_queue, CL_mem, CL_mem, Csize_t, Ptr{Csize_t}, Ptr{Csize_t}, CL_uint, Ptr{CL_event}, Ptr{CL_event})) -@ocl_func_1_0(clEnqueueMapBuffer, Ptr{Void}, +@ocl_func(clEnqueueMapBuffer, Ptr{Void}, (CL_command_queue, CL_mem, CL_bool, CL_map_flags, Csize_t, Csize_t, CL_uint, Ptr{CL_event}, Ptr{CL_event}, Ptr{CL_int})) -@ocl_func_1_0(clEnqueueMapImage, Ptr{Void}, +@ocl_func(clEnqueueMapImage, Ptr{Void}, (CL_command_queue, CL_mem, CL_bool, CL_map_flags, - Ptr{Csize_t}, Ptr{Csize_t}, Ptr{Csize_t}, Ptr{Csize_t}, + Ptr{Csize_t}, Ptr{Csize_t}, Ptr{Csize_t}, Ptr{Csize_t}, CL_uint, Ptr{CL_event}, Ptr{CL_event}, Ptr{CL_int})) -@ocl_func_1_0(clEnqueueUnmapMemObject, CL_int, +@ocl_func(clEnqueueUnmapMemObject, CL_int, (CL_command_queue, CL_mem, Ptr{Void}, CL_uint, Ptr{CL_event}, Ptr{CL_event})) -@ocl_func_1_0(clEnqueueNDRangeKernel, CL_int, +@ocl_func(clEnqueueNDRangeKernel, CL_int, (CL_command_queue, CL_kernel, CL_uint, Ptr{Csize_t}, Ptr{Csize_t}, Ptr{Csize_t}, CL_uint, Ptr{CL_event}, Ptr{CL_event})) - -@ocl_func_1_0(clEnqueueTask, CL_int, + +@ocl_func(clEnqueueTask, CL_int, (CL_command_queue, CL_kernel, CL_uint, Ptr{CL_event}, Ptr{CL_event})) -@ocl_func_1_0(clEnqueueNativeKernel, CL_int, - (CL_command_queue, Ptr{Void}, Csize_t, CL_uint, +@ocl_func(clEnqueueNativeKernel, CL_int, + (CL_command_queue, Ptr{Void}, Csize_t, CL_uint, Ptr{CL_mem}, Ptr{Ptr{Void}}, CL_uint, Ptr{CL_event}, Ptr{CL_event})) \ No newline at end of file diff --git a/src/api/opencl_11.jl b/src/api/opencl_11.jl index 99f690cc..001ea836 100644 --- a/src/api/opencl_11.jl +++ b/src/api/opencl_11.jl @@ -1,61 +1,61 @@ #=== memory object apis ===# -@ocl_func_1_1(clCreateSubBuffer, CL_mem, +@ocl_func(clCreateSubBuffer, CL_mem, (CL_mem, CL_mem_flags, CL_buffer_create_type, Ptr{Void}, Ptr{CL_int})) -@ocl_func_1_1(clSetMemObjectDestructorCallback, CL_int, +@ocl_func(clSetMemObjectDestructorCallback, CL_int, (CL_mem, CL_callback, Ptr{Void})) #=== program object apis ===# -@ocl_func_1_1(clGetProgramInfo, CL_int, +@ocl_func(clGetProgramInfo, CL_int, (CL_program, CL_program_info, Csize_t, Ptr{Void}, Ptr{Csize_t})) #=== event object apis ===# -@ocl_func_1_1(clCreateUserEvent, CL_event, +@ocl_func(clCreateUserEvent, CL_event, (CL_context, Ptr{CL_int})) -@ocl_func_1_1(clSetUserEventStatus, CL_int, (CL_event, CL_int)) +@ocl_func(clSetUserEventStatus, CL_int, (CL_event, CL_int)) -@ocl_func_1_1(clSetEventCallback, CL_int, +@ocl_func(clSetEventCallback, CL_int, (CL_event, CL_int, CL_callback, CL_user_data)) #=== enqueued commands apis ===# -@ocl_func_1_1(clEnqueueReadBufferRect, CL_int, +@ocl_func(clEnqueueReadBufferRect, CL_int, (CL_command_queue, CL_mem, CL_bool, - Ptr{Csize_t}, Ptr{Csize_t}, Ptr{Csize_t}, + Ptr{Csize_t}, Ptr{Csize_t}, Ptr{Csize_t}, Csize_t, Csize_t, Csize_t, Csize_t, Ptr{Void}, CL_uint, Ptr{CL_event}, Ptr{CL_event})) -@ocl_func_1_1(clEnqueueWriteBufferRect, CL_int, - (CL_command_queue, CL_mem, CL_bool, - Ptr{Csize_t}, Ptr{Csize_t}, Ptr{Csize_t}, - Csize_t, Csize_t, Csize_t, Csize_t, +@ocl_func(clEnqueueWriteBufferRect, CL_int, + (CL_command_queue, CL_mem, CL_bool, + Ptr{Csize_t}, Ptr{Csize_t}, Ptr{Csize_t}, + Csize_t, Csize_t, Csize_t, Csize_t, Ptr{Void}, CL_uint, Ptr{CL_event}, Ptr{CL_event})) -@ocl_func_1_1(clEnqueueCopyBufferRect, CL_int, +@ocl_func(clEnqueueCopyBufferRect, CL_int, (CL_command_queue, CL_mem, CL_mem, - Ptr{Csize_t}, Ptr{Csize_t}, Ptr{Csize_t}, + Ptr{Csize_t}, Ptr{Csize_t}, Ptr{Csize_t}, Csize_t, Csize_t, Csize_t, Csize_t, CL_uint, Ptr{CL_event}, Ptr{CL_event})) #=== extension function access ===# -@ocl_func_1_1(clGetExtensionFunctionAddress, Ptr{Void}, (Ptr{Cchar},)) +@ocl_func(clGetExtensionFunctionAddress, Ptr{Void}, (Ptr{Cchar},)) #=== deprecated functions ===# -@ocl_func_1_1(clCreateImage2D, CL_mem, +@ocl_func(clCreateImage2D, CL_mem, (CL_context, CL_mem_flags, Ptr{CL_image_format}, Csize_t, Csize_t, Csize_t, Ptr{Void}, Ptr{CL_int})) -@ocl_func_1_1(clCreateImage3D, CL_mem, +@ocl_func(clCreateImage3D, CL_mem, (CL_context, CL_mem_flags, Ptr{CL_image_format}, Csize_t, Csize_t, Csize_t, Csize_t, Ptr{Void}, Ptr{CL_int})) -@ocl_func_1_1(clEnqueueMarker, CL_int, +@ocl_func(clEnqueueMarker, CL_int, (CL_command_queue, Ptr{CL_event})) -@ocl_func_1_1(clEnqueueWaitForEvents, CL_int, +@ocl_func(clEnqueueWaitForEvents, CL_int, (CL_command_queue, CL_uint, Ptr{CL_event})) -@ocl_func_1_1(clEnqueueBarrier, CL_int, +@ocl_func(clEnqueueBarrier, CL_int, (CL_command_queue,)) -@ocl_func_1_1(clUnloadCompiler, CL_int, ()) \ No newline at end of file +@ocl_func(clUnloadCompiler, CL_int, ()) \ No newline at end of file diff --git a/src/api/opencl_12.jl b/src/api/opencl_12.jl index 7f27b89d..147cec51 100644 --- a/src/api/opencl_12.jl +++ b/src/api/opencl_12.jl @@ -1,54 +1,54 @@ #=== device apis ===# -@ocl_func_1_2(clCreateSubDevices, CL_int, +@ocl_func(clCreateSubDevices, CL_int, (CL_device_id, CL_device_partition_property, CL_uint, Ptr{CL_device_id}, Ptr{CL_uint})) -@ocl_func_1_2(clRetainDevice, CL_int, (CL_device_id,)) +@ocl_func(clRetainDevice, CL_int, (CL_device_id,)) -@ocl_func_1_2(clReleaseDevice, CL_int, (CL_device_id,)) +@ocl_func(clReleaseDevice, CL_int, (CL_device_id,)) #=== memory object apis ===# -@ocl_func_1_2(clCreateImage, CL_mem, +@ocl_func(clCreateImage, CL_mem, (CL_context, CL_mem_flags, CL_image_format, CL_image_desc, Ptr{Void}, Ptr{CL_int})) #=== program object apis ===# -@ocl_func_1_2(clCreateProgramWithBuiltInKernels, CL_program, +@ocl_func(clCreateProgramWithBuiltInKernels, CL_program, (CL_context, CL_uint, Ptr{CL_device_id}, Ptr{Cchar}, Ptr{CL_int})) -@ocl_func_1_2(clCompileProgram, CL_int, - (CL_program, CL_uint, Ptr{CL_device_id}, Ptr{CL_device_id}, Ptr{Cchar}, +@ocl_func(clCompileProgram, CL_int, + (CL_program, CL_uint, Ptr{CL_device_id}, Ptr{CL_device_id}, Ptr{Cchar}, CL_uint, Ptr{CL_program}, Ptr{Ptr{Char}}, CL_callback, Ptr{Void})) -@ocl_func_1_2(clLinkProgram, CL_program, +@ocl_func(clLinkProgram, CL_program, (CL_context, CL_uint, Ptr{CL_device_id}, Ptr{Cchar}, CL_uint, CL_callback, Ptr{Void}, Ptr{CL_int})) -@ocl_func_1_2(clUnloadPlatformCompiler, CL_int, (CL_platform_id,)) +@ocl_func(clUnloadPlatformCompiler, CL_int, (CL_platform_id,)) #=== kernel object apis ===# -@ocl_func_1_2(clGetKernelArgInfo, CL_int, +@ocl_func(clGetKernelArgInfo, CL_int, (CL_kernel, CL_uint, CL_kernel_arg_info, Csize_t, Ptr{Void}, Ptr{Csize_t})) #=== enqueued commands apis ===# -@ocl_func_1_2(clEnqueueFillBuffer, CL_int, - (CL_command_queue, CL_mem, Ptr{Void}, Csize_t, Csize_t, Csize_t, +@ocl_func(clEnqueueFillBuffer, CL_int, + (CL_command_queue, CL_mem, Ptr{Void}, Csize_t, Csize_t, Csize_t, CL_uint, Ptr{CL_event}, Ptr{CL_event})) -@ocl_func_1_2(clEnqueueFillImage, CL_int, - (CL_command_queue, CL_mem, Ptr{Void}, Ptr{Csize_t}, Ptr{Csize_t}, +@ocl_func(clEnqueueFillImage, CL_int, + (CL_command_queue, CL_mem, Ptr{Void}, Ptr{Csize_t}, Ptr{Csize_t}, CL_uint, Ptr{CL_event}, Ptr{CL_event})) -@ocl_func_1_2(clEnqueueMigrateMemObjects, CL_int, +@ocl_func(clEnqueueMigrateMemObjects, CL_int, (CL_command_queue, CL_uint, Ptr{CL_mem}, CL_mem_migration_flags, CL_uint, Ptr{CL_event}, Ptr{CL_event})) -@ocl_func_1_2(clEnqueueMarkerWithWaitList, CL_int, +@ocl_func(clEnqueueMarkerWithWaitList, CL_int, (CL_command_queue, CL_uint, Ptr{CL_event}, Ptr{CL_event})) -@ocl_func_1_2(clEnqueueBarrierWithWaitList, CL_int, +@ocl_func(clEnqueueBarrierWithWaitList, CL_int, (CL_command_queue, CL_uint, Ptr{CL_event}, Ptr{CL_event})) #=== extension function access ===# -@ocl_func_1_2(clGetExtensionFunctionAddressForPlatform, Ptr{Void}, +@ocl_func(clGetExtensionFunctionAddressForPlatform, Ptr{Void}, (CL_platform_id, Ptr{Cchar})) #=== deprecation ===# From 479dd7462c74dec22f2bfba45fa34994db5c9fa7 Mon Sep 17 00:00:00 2001 From: Valentin Churavy Date: Wed, 13 Aug 2014 08:56:17 +0200 Subject: [PATCH 4/7] reorder api functions --- src/api/opencl_11.jl | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/src/api/opencl_11.jl b/src/api/opencl_11.jl index 001ea836..b73b0d20 100644 --- a/src/api/opencl_11.jl +++ b/src/api/opencl_11.jl @@ -1,3 +1,6 @@ +#=== compiler apis ===# +@ocl_func(clUnloadCompiler, CL_int, ()) + #=== memory object apis ===# @ocl_func(clCreateSubBuffer, CL_mem, (CL_mem, CL_mem_flags, CL_buffer_create_type, Ptr{Void}, Ptr{CL_int})) @@ -5,6 +8,14 @@ @ocl_func(clSetMemObjectDestructorCallback, CL_int, (CL_mem, CL_callback, Ptr{Void})) +@ocl_func(clCreateImage2D, CL_mem, + (CL_context, CL_mem_flags, Ptr{CL_image_format}, Csize_t, Csize_t, Csize_t, + Ptr{Void}, Ptr{CL_int})) + +@ocl_func(clCreateImage3D, CL_mem, + (CL_context, CL_mem_flags, Ptr{CL_image_format}, Csize_t, Csize_t, Csize_t, + Csize_t, Ptr{Void}, Ptr{CL_int})) + #=== program object apis ===# @ocl_func(clGetProgramInfo, CL_int, (CL_program, CL_program_info, Csize_t, Ptr{Void}, Ptr{Csize_t})) @@ -37,18 +48,6 @@ Csize_t, Csize_t, Csize_t, Csize_t, CL_uint, Ptr{CL_event}, Ptr{CL_event})) -#=== extension function access ===# -@ocl_func(clGetExtensionFunctionAddress, Ptr{Void}, (Ptr{Cchar},)) - -#=== deprecated functions ===# -@ocl_func(clCreateImage2D, CL_mem, - (CL_context, CL_mem_flags, Ptr{CL_image_format}, Csize_t, Csize_t, Csize_t, - Ptr{Void}, Ptr{CL_int})) - -@ocl_func(clCreateImage3D, CL_mem, - (CL_context, CL_mem_flags, Ptr{CL_image_format}, Csize_t, Csize_t, Csize_t, - Csize_t, Ptr{Void}, Ptr{CL_int})) - @ocl_func(clEnqueueMarker, CL_int, (CL_command_queue, Ptr{CL_event})) @@ -58,4 +57,5 @@ @ocl_func(clEnqueueBarrier, CL_int, (CL_command_queue,)) -@ocl_func(clUnloadCompiler, CL_int, ()) \ No newline at end of file +#=== extension function access ===# +@ocl_func(clGetExtensionFunctionAddress, Ptr{Void}, (Ptr{Cchar},)) From b7461e1258d1dfe85eed915377e4d8f863f880da Mon Sep 17 00:00:00 2001 From: Valentin Churavy Date: Tue, 19 Aug 2014 15:42:11 +0200 Subject: [PATCH 5/7] removes superflous macros --- src/macros.jl | 22 ---------------------- 1 file changed, 22 deletions(-) diff --git a/src/macros.jl b/src/macros.jl index d1e85acc..9b83a336 100644 --- a/src/macros.jl +++ b/src/macros.jl @@ -1,25 +1,3 @@ -macro ocl_call(func, arg_types, args...) - quote - _err = ccall(($func, libopencl), CL_int, $arg_types, $(args...)) - if _err != CL_SUCCESS - error("CL ERROR: $func") - end - end -end - -macro ocl_call(func, ret_type, arg_types, args...) - quote - ccall(($func, libopencl), $ret_type, $arg_types, $(args...)) - end -end - -macro ocl_func(func, arg_types) - local args_in = Symbol[symbol(string('a', i)) for i in 1:length(arg_types.args)] - quote - $(esc(func))($(args_in...)) = @ocl_call($(string(func)), $arg_types, $(args_in...)) - end -end - macro check(clfunc) quote local err::CL_int From b615753d47be1c1d88b4af816c32d5bb3282e84f Mon Sep 17 00:00:00 2001 From: Valentin Churavy Date: Tue, 19 Aug 2014 15:54:59 +0200 Subject: [PATCH 6/7] move parse_version to api --- src/api.jl | 8 ++++++++ src/util.jl | 10 +--------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/api.jl b/src/api.jl index 56dfd532..fd41d56e 100644 --- a/src/api.jl +++ b/src/api.jl @@ -32,4 +32,12 @@ include("api/opencl_10.jl") include("api/opencl_11.jl") include("api/opencl_12.jl") +function parse_version(version_string) + mg = match(r"^OpenCL ([0-9]+)\.([0-9]+) .*$", version_string) + if mg == nothing + error("Non conform version string: $(ver)") + end + return VersionNumber(int(mg.captures[1]), int(mg.captures[2])) +end + end diff --git a/src/util.jl b/src/util.jl index 7c2ad3aa..c5d1d862 100644 --- a/src/util.jl +++ b/src/util.jl @@ -5,15 +5,7 @@ function create_compute_context() return (device, ctx, queue) end -function opencl_version(p::Platform) - ver = p[:version] - mg = match(r"^OpenCL ([0-9]+)\.([0-9]+) .*$", ver) - if mg == nothing - error("Platform $(p[:name]) returns non conformat platform string: $(ver)") - end - return VersionNumber(int(mg.captures[1]), int(mg.captures[2])) -end - +opencl_version(p::Platform) = api.parse_version(p[:version]) opencl_version(d::Device) = opencl_version(d[:platform]) opencl_version(c::Context) = opencl_version(first(devices(c))) opencl_version(q::CmdQueue) = opencl_version(q[:context]) From 0fcc9808552191d9ea792d4b09ae5b002d60d5e9 Mon Sep 17 00:00:00 2001 From: Jake Bolewski Date: Fri, 22 Aug 2014 14:51:21 -0400 Subject: [PATCH 7/7] formatting fixes --- src/api.jl | 24 ++++++++++++++--------- src/api/{opencl_10.jl => opencl_1.0.0.jl} | 0 src/api/{opencl_11.jl => opencl_1.1.0.jl} | 0 src/api/{opencl_12.jl => opencl_1.2.0.jl} | 0 4 files changed, 15 insertions(+), 9 deletions(-) rename src/api/{opencl_10.jl => opencl_1.0.0.jl} (100%) rename src/api/{opencl_11.jl => opencl_1.1.0.jl} (100%) rename src/api/{opencl_12.jl => opencl_1.2.0.jl} (100%) diff --git a/src/api.jl b/src/api.jl index fd41d56e..e4733637 100644 --- a/src/api.jl +++ b/src/api.jl @@ -14,28 +14,34 @@ end const libopencl = "OpenCL" end -macro ocl_func(func, ret_type, arg_types) +function _ocl_func(func, ret_type, arg_types) local args_in = Symbol[symbol("arg$i::$T") for (i, T) in enumerate(arg_types.args)] esc(quote - $func($(args_in...)) = ccall(($(string(func)), libopencl), - $ret_type, - $arg_types, - $(args_in...)) + function $func($(args_in...)) + ccall(($(string(func)), libopencl), + $ret_type, + $arg_types, + $(args_in...)) + end end) end +macro ocl_func(func, ret_type, arg_types) + _ocl_func(func, ret_type, arg_types) +end + typealias CL_callback Ptr{Void} typealias CL_user_data Any -include("api/opencl_10.jl") -include("api/opencl_11.jl") -include("api/opencl_12.jl") +include("api/opencl_1.0.0.jl") +include("api/opencl_1.1.0.jl") +include("api/opencl_1.2.0.jl") function parse_version(version_string) mg = match(r"^OpenCL ([0-9]+)\.([0-9]+) .*$", version_string) if mg == nothing - error("Non conform version string: $(ver)") + error("Non conforming version string: $(ver)") end return VersionNumber(int(mg.captures[1]), int(mg.captures[2])) end diff --git a/src/api/opencl_10.jl b/src/api/opencl_1.0.0.jl similarity index 100% rename from src/api/opencl_10.jl rename to src/api/opencl_1.0.0.jl diff --git a/src/api/opencl_11.jl b/src/api/opencl_1.1.0.jl similarity index 100% rename from src/api/opencl_11.jl rename to src/api/opencl_1.1.0.jl diff --git a/src/api/opencl_12.jl b/src/api/opencl_1.2.0.jl similarity index 100% rename from src/api/opencl_12.jl rename to src/api/opencl_1.2.0.jl