Exemple #1
0
        public static IntPtr CreateProgramWithBinary(IntPtr context, uint num_devices, IntPtr[] device_list, IntPtr[] lengths, byte[][] binaries, int[] binary_status, out ErrorCode errcode_ret)
        {
            IntPtr program;

            GCHandle[] pinnedArrays = new GCHandle[binaries.Length];
            // Pin arrays
            for (int i = 0; i < binaries.Length; i++)
            {
                pinnedArrays[i] = GCHandle.Alloc(binaries[i], GCHandleType.Pinned);
            }

            IntPtr[] pointerArray = new IntPtr[binaries.Length];
            for (int i = 0; i < binaries.Length; i++)
            {
                pointerArray[i] = pinnedArrays[i].AddrOfPinnedObject();
            }

            program = OpenCLAPI.clCreateProgramWithBinary(context, num_devices, device_list, lengths, pointerArray, binary_status, out errcode_ret);

            for (int i = 0; i < binaries.Length; i++)
            {
                pinnedArrays[i].Free();
            }

            return(program);
        }
Exemple #2
0
        public static ErrorCode SetCommandQueueProperty(IntPtr command_queue, ulong properties, bool enable, out ulong old_properties)
        {
#pragma warning disable 618
            return(OpenCLAPI.clSetCommandQueueProperty(command_queue, properties, enable, out old_properties));

#pragma warning restore 618
        }
		public static void* EnqueueMapImage(IntPtr command_queue, IntPtr image, UInt32 blocking_map, UInt64 map_flags, IntPtr* origin, IntPtr* region, out Int64 image_row_pitch, out Int64 image_slice_pitch, Int32 num_events_in_wait_list, IntPtr* event_wait_list, IntPtr* _event, out ErrorCode errcode_ret) {
			IntPtr rowPitch;
			IntPtr slicePitch;
			void* p;
			p = OpenCLAPI.clEnqueueMapImage(command_queue, image, blocking_map, map_flags, origin, region, out rowPitch, out slicePitch, (UInt32)num_events_in_wait_list, event_wait_list, _event, out errcode_ret);
			image_row_pitch = rowPitch.ToInt64();
			image_slice_pitch = slicePitch.ToInt64();
			return p;
		}
Exemple #4
0
 public static ErrorCode EnqueueNativeKernel(cl_command_queue command_queue,
                                             NativeKernelInternal user_func,
                                             void *args,
                                             IntPtr cb_args,
                                             cl_uint num_mem_objects,
                                             cl_mem[] mem_list,
                                             IntPtr[] args_mem_loc,
                                             cl_uint num_events_in_wait_list,
                                             cl_event[] event_wait_list,
                                             cl_event *_event)
 {
     return(OpenCLAPI.clEnqueueNativeKernel(command_queue,
                                            user_func,
                                            args,
                                            cb_args,
                                            num_mem_objects,
                                            mem_list,
                                            args_mem_loc,
                                            num_events_in_wait_list,
                                            event_wait_list,
                                            _event));
 }
Exemple #5
0
        static OpenCLAPI()
        {
#if D3D10_Extension
            {
                // Get function pointers for D3D10 extension
                IntPtr func;
                func = OpenCLAPI.clGetExtensionFunctionAddress("clGetDeviceIDsFromD3D10KHR");
                if (func != IntPtr.Zero)
                {
                    OpenCLAPI.clGetDeviceIDsFromD3D10KHR = (clGetDeviceIDsFromD3D10KHRDelegate)Marshal.GetDelegateForFunctionPointer(func, typeof(clGetDeviceIDsFromD3D10KHRDelegate));
                }
                func = OpenCLAPI.clGetExtensionFunctionAddress("clCreateFromD3D10BufferKHR");
                if (func != IntPtr.Zero)
                {
                    OpenCLAPI.clCreateFromD3D10BufferKHR = (clCreateFromD3D10BufferKHRDelegate)Marshal.GetDelegateForFunctionPointer(func, typeof(clCreateFromD3D10BufferKHRDelegate));
                }
                func = OpenCLAPI.clGetExtensionFunctionAddress("clCreateFromD3D10Texture2DKHR");
                if (func != IntPtr.Zero)
                {
                    OpenCLAPI.clCreateFromD3D10Texture2DKHR = (clCreateFromD3D10Texture2DKHRDelegate)Marshal.GetDelegateForFunctionPointer(func, typeof(clCreateFromD3D10Texture2DKHRDelegate));
                }
                func = OpenCLAPI.clGetExtensionFunctionAddress("clCreateFromD3D10Texture3DKHR");
                if (func != IntPtr.Zero)
                {
                    OpenCLAPI.clCreateFromD3D10Texture3DKHR = (clCreateFromD3D10Texture3DKHRDelegate)Marshal.GetDelegateForFunctionPointer(func, typeof(clCreateFromD3D10Texture3DKHRDelegate));
                }
                func = OpenCLAPI.clGetExtensionFunctionAddress("clEnqueueAcquireD3D10ObjectsKHR");
                if (func != IntPtr.Zero)
                {
                    OpenCLAPI.clEnqueueAcquireD3D10ObjectsKHR = (clEnqueueAcquireD3D10ObjectsKHRDelegate)Marshal.GetDelegateForFunctionPointer(func, typeof(clEnqueueAcquireD3D10ObjectsKHRDelegate));
                }
                func = OpenCLAPI.clGetExtensionFunctionAddress("clEnqueueReleaseD3D10ObjectsKHR");
                if (func != IntPtr.Zero)
                {
                    OpenCLAPI.clEnqueueReleaseD3D10ObjectsKHR = (clEnqueueReleaseD3D10ObjectsKHRDelegate)Marshal.GetDelegateForFunctionPointer(func, typeof(clEnqueueReleaseD3D10ObjectsKHRDelegate));
                }
            }
#endif

#if DEVICE_FISSION_Extension
            {
                // Get function pointers for the device fission extension
                IntPtr func;
                func = OpenCLAPI.clGetExtensionFunctionAddress("clReleaseDeviceEXT");
                if (func != IntPtr.Zero)
                {
                    OpenCLAPI.clReleaseDeviceEXT = (clReleaseDeviceEXTDelegate)Marshal.GetDelegateForFunctionPointer(func, typeof(clReleaseDeviceEXTDelegate));
                }
                func = OpenCLAPI.clGetExtensionFunctionAddress("clRetainDeviceEXT");
                if (func != IntPtr.Zero)
                {
                    OpenCLAPI.clRetainDeviceEXT = (clRetainDeviceEXTDelegate)Marshal.GetDelegateForFunctionPointer(func, typeof(clRetainDeviceEXTDelegate));
                }
                func = OpenCLAPI.clGetExtensionFunctionAddress("clCreateSubDevicesEXT");
                if (func != IntPtr.Zero)
                {
                    OpenCLAPI.clCreateSubDevicesEXT = (clCreateSubDevicesEXTDelegate)Marshal.GetDelegateForFunctionPointer(func, typeof(clCreateSubDevicesEXTDelegate));
                }
            }
#endif
        }
Exemple #6
0
 // Extension function access
 public static IntPtr GetExtensionFunctionAddress(string func_name)
 {
     return(OpenCLAPI.clGetExtensionFunctionAddress(func_name));
 }
Exemple #7
0
 public static ErrorCode RetainDeviceEXT(cl_device_id device)
 {
     return(OpenCLAPI.clRetainDeviceEXT(device));
 }
Exemple #8
0
 public static ErrorCode GetGLTextureInfo(cl_mem memobj, cl_gl_texture_info param_name, IntPtr param_value_size, void *param_value, out IntPtr param_value_size_ret)
 {
     return(OpenCLAPI.clGetGLTextureInfo(memobj, param_name, param_value_size, param_value, out param_value_size_ret));
 }
Exemple #9
0
 public static cl_mem CreateFromGLRenderbuffer(cl_context context, cl_mem_flags flags, GLuint renderbuffer, out ErrorCode errcode_ret)
 {
     return(OpenCLAPI.clCreateFromGLRenderbuffer(context, flags, renderbuffer, out errcode_ret));
 }
Exemple #10
0
 public static ErrorCode GetSamplerInfo(cl_sampler sampler, cl_sampler_info param_name, IntPtr param_value_size, void *param_value, out IntPtr param_value_size_ret)
 {
     return(OpenCLAPI.clGetSamplerInfo(sampler, param_name, param_value_size, param_value, out param_value_size_ret));
 }
Exemple #11
0
 public static ErrorCode EnqueueCopyBufferRect(cl_command_queue command_queue, cl_mem src_buffer, cl_mem dst_buffer, IntPtr *src_origin, IntPtr *dst_origin, IntPtr *region, long src_row_pitch, long src_slice_pitch, long dst_row_pitch, long dst_slice_pitch, int num_events_in_wait_list, cl_event *_event_wait_list, cl_event *_event)
 {
     return(OpenCLAPI.clEnqueueCopyBufferRect(command_queue, src_buffer, dst_buffer, src_origin, dst_origin, region, (IntPtr)src_row_pitch, (IntPtr)src_slice_pitch, (IntPtr)dst_row_pitch, (IntPtr)dst_slice_pitch, (uint)num_events_in_wait_list, _event_wait_list, _event));
 }
Exemple #12
0
 /// <summary>
 /// OpenCL 1.1
 /// </summary>
 /// <param name="command_queue"></param>
 /// <param name="src_buffer"></param>
 /// <param name="dst_buffer"></param>
 /// <param name="src_origin"></param>
 /// <param name="dst_origin"></param>
 /// <param name="region"></param>
 /// <param name="src_row_pitch"></param>
 /// <param name="src_slice_pitch"></param>
 /// <param name="dst_row_pitch"></param>
 /// <param name="dst_slice_pitch"></param>
 /// <param name="num_events_in_wait_list"></param>
 /// <param name="_event_wait_list"></param>
 /// <param name="_event"></param>
 /// <returns></returns>
 public static ErrorCode EnqueueCopyBufferRect(cl_command_queue command_queue, cl_mem src_buffer, cl_mem dst_buffer, IntPtr[] src_origin, IntPtr[] dst_origin, IntPtr[] region, IntPtr src_row_pitch, IntPtr src_slice_pitch, IntPtr dst_row_pitch, IntPtr dst_slice_pitch, cl_uint num_events_in_wait_list, cl_event[] _event_wait_list, cl_event *_event)
 {
     return(OpenCLAPI.clEnqueueCopyBufferRect(command_queue, src_buffer, dst_buffer, src_origin, dst_origin, region, src_row_pitch, src_slice_pitch, dst_row_pitch, dst_slice_pitch, num_events_in_wait_list, _event_wait_list, _event));
 }
Exemple #13
0
 public static ErrorCode EnqueueWriteBufferRect(cl_command_queue command_queue, cl_mem buffer, cl_bool blocking_write, IntPtr *buffer_offset, IntPtr *host_offset, IntPtr *region, long buffer_row_pitch, long buffer_slice_pitch, long host_row_pitch, long host_slice_pitch, void *ptr, int num_events_in_wait_list, cl_event *_event_wait_list, cl_event *_event)
 {
     return(OpenCLAPI.clEnqueueWriteBufferRect(command_queue, buffer, blocking_write, buffer_offset, host_offset, region, (IntPtr)buffer_row_pitch, (IntPtr)buffer_slice_pitch, (IntPtr)host_row_pitch, (IntPtr)host_slice_pitch, ptr, (uint)num_events_in_wait_list, _event_wait_list, _event));
 }
Exemple #14
0
 /// <summary>
 /// OpenCL 1.1
 /// </summary>
 /// <param name="command_queue"></param>
 /// <param name="buffer"></param>
 /// <param name="blocking_read"></param>
 /// <param name="buffer_offset"></param>
 /// <param name="host_offset"></param>
 /// <param name="region"></param>
 /// <param name="buffer_row_pitch"></param>
 /// <param name="buffer_slice_pitch"></param>
 /// <param name="host_row_pitch"></param>
 /// <param name="host_slice_pitch"></param>
 /// <param name="ptr"></param>
 /// <param name="num_events_in_wait_list"></param>
 /// <param name="_event_wait_list"></param>
 /// <param name="_event"></param>
 /// <returns></returns>
 public static ErrorCode EnqueueWriteBufferRect(cl_command_queue command_queue, cl_mem buffer, cl_bool blocking_write, IntPtr[] buffer_offset, IntPtr[] host_offset, IntPtr[] region, IntPtr buffer_row_pitch, IntPtr buffer_slice_pitch, IntPtr host_row_pitch, IntPtr host_slice_pitch, void *ptr, cl_uint num_events_in_wait_list, cl_event[] _event_wait_list, cl_event *_event)
 {
     return(OpenCLAPI.clEnqueueWriteBufferRect(command_queue, buffer, blocking_write, buffer_offset, host_offset, region, buffer_row_pitch, buffer_slice_pitch, host_row_pitch, host_slice_pitch, ptr, num_events_in_wait_list, _event_wait_list, _event));
 }
Exemple #15
0
 public static ErrorCode EnqueueBarrier(IntPtr command_queue)
 {
     return(OpenCLAPI.clEnqueueBarrier(command_queue));
 }
Exemple #16
0
 public static cl_sampler CreateSampler(cl_context context, bool normalized_coords, cl_addressing_mode addressing_mode, cl_filter_mode filter_mode, out ErrorCode errcode_ret)
 {
     return(OpenCLAPI.clCreateSampler(context, normalized_coords ? (cl_bool)Bool.TRUE : (cl_bool)Bool.FALSE, addressing_mode, filter_mode, out errcode_ret));
 }
Exemple #17
0
 public static ErrorCode ReleaseSampler(cl_sampler sampler)
 {
     return(OpenCLAPI.clReleaseSampler(sampler));
 }
Exemple #18
0
 public static ErrorCode Finish(cl_command_queue command_queue)
 {
     return(OpenCLAPI.clFinish(command_queue));
 }
Exemple #19
0
 public static cl_mem CreateFromGLTexture3D(cl_context context, cl_mem_flags flags, GLenum target, GLint mipLevel, GLuint texture, out ErrorCode errcode_ret)
 {
     return(OpenCLAPI.clCreateFromGLTexture3D(context, flags, target, mipLevel, texture, out errcode_ret));
 }
Exemple #20
0
 public static ErrorCode WaitForEvents(cl_uint num_events, cl_event[] _event_list)
 {
     return(OpenCLAPI.clWaitForEvents(num_events, _event_list));
 }
Exemple #21
0
 public static ErrorCode GetGLObjectInfo(cl_mem memobj, out cl_gl_object_type gl_object_type, out GLuint gl_object_name)
 {
     return(OpenCLAPI.clGetGLObjectInfo(memobj, out gl_object_type, out gl_object_name));
 }
Exemple #22
0
 public static ErrorCode GetEventInfo(cl_event _event, cl_event_info param_name, IntPtr param_value_size, void *param_value, out IntPtr param_value_size_ret)
 {
     return(OpenCLAPI.clGetEventInfo(_event, param_name, param_value_size, param_value, out param_value_size_ret));
 }
Exemple #23
0
 public static ErrorCode EnqueueReleaseGLObjects(cl_command_queue command_queue, cl_uint num_objects, cl_mem[] mem_objects, cl_uint num_events_in_wait_list, cl_event[] event_wait_list, cl_event *_event)
 {
     return(OpenCLAPI.clEnqueueAcquireGLObjects(command_queue, num_objects, mem_objects, num_events_in_wait_list, event_wait_list, _event));
 }
Exemple #24
0
 public static ErrorCode ReleaseEvent(cl_event _event)
 {
     return(OpenCLAPI.clReleaseEvent(_event));
 }
Exemple #25
0
 public static ErrorCode CreateSubDevicesEXT(cl_device_id in_device, byte[] properties, cl_uint num_entries, cl_device_id[] out_devices, [Out] cl_uint *num_devices)
 {
     return(OpenCLAPI.clCreateSubDevicesEXT(in_device, properties, num_entries, out_devices, num_devices));
 }
Exemple #26
0
 /// <summary>
 /// OpenCL 1.1
 /// </summary>
 /// <param name="context"></param>
 /// <param name="errcode_ret"></param>
 /// <returns></returns>
 public static cl_event CreateUserEvent(cl_context context, out ErrorCode errcode_ret)
 {
     return(OpenCLAPI.clCreateUserEvent(context, out errcode_ret));
 }
Exemple #27
0
 public static ErrorCode GetEventProfilingInfo(cl_event _event, ProfilingInfo param_name, IntPtr param_value_size, void *param_value, out IntPtr param_value_size_ret)
 {
     return((ErrorCode)OpenCLAPI.clGetEventProfilingInfo(_event, (uint)param_name, param_value_size, param_value, out param_value_size_ret));
 }
Exemple #28
0
 /// <summary>
 /// OpenCL 1.1
 /// </summary>
 /// <param name="_event"></param>
 /// <param name="execution_status"></param>
 /// <returns></returns>
 public static ErrorCode SetUserEventStatus(cl_event _event, ExecutionStatus execution_status)
 {
     return(OpenCLAPI.clSetUserEventStatus(_event, execution_status));
 }
Exemple #29
0
        static GLSharing()
        {
            IntPtr func = OpenCLAPI.clGetExtensionFunctionAddress("clGetGLContextInfoKHR");

            clGetGLContextInfoKHR = (clGetGLContextInfoKHRDelegate)Marshal.GetDelegateForFunctionPointer(func, typeof(clGetGLContextInfoKHRDelegate));
        }
Exemple #30
0
 /// <summary>
 /// OpenCL 1.1
 /// </summary>
 /// <param name="_event"></param>
 /// <param name="command_exec_callback_type"></param>
 /// <param name="pfn_notify"></param>
 /// <param name="user_data"></param>
 /// <returns></returns>
 public static ErrorCode SetEventCallback(cl_event _event, cl_int command_exec_callback_type, EventNotifyInternal pfn_notify, IntPtr user_data)
 {
     return(OpenCLAPI.clSetEventCallback(_event, command_exec_callback_type, pfn_notify, user_data));
 }