Esempio n. 1
0
        /// <summary>
        /// OpenCL 1.1
        /// </summary>
        /// <param name="_event"></param>
        /// <param name="execution_status"></param>
        public void SetUserEventStatus(ExecutionStatus execution_status)
        {
            ErrorCode result;

            result = OpenCL.SetUserEventStatus(EventID, execution_status);
            if (result != ErrorCode.SUCCESS)
            {
                throw new OpenCLException("SetUserEventStatus failed with error code " + result, result);
            }
        }
Esempio n. 2
0
        /// <summary>
        ///     Set argument argIndex to c
        /// </summary>
        /// <param name="argIndex"></param>
        /// <param name="c"></param>
        public void SetArg(Int32 argIndex, System.UInt16 c)
        {
            ErrorCode result;

            result = OpenCL.SetKernelArg(this.KernelID, (UInt32)argIndex, new IntPtr(sizeof(System.UInt16)), &c);
            if (result != ErrorCode.SUCCESS)
            {
                throw new OpenCLException("SetArg failed with error code " + result, result);
            }
        }
Esempio n. 3
0
        public void SetArg(Int32 argIndex, Double2 c)
        {
            ErrorCode result;

            result = OpenCL.SetKernelArg(this.KernelID, (UInt32)argIndex, (IntPtr)sizeof(Double2), &c);
            if (result != ErrorCode.SUCCESS)
            {
                throw new OpenCLException("SetArg failed with error code " + result, result);
            }
        }
Esempio n. 4
0
        public void SetByteArg(int argIndex, byte c)
        {
            ErrorCode result;

            result = (ErrorCode)OpenCL.SetKernelArg(KernelID, (uint)argIndex, new IntPtr(sizeof(byte)), &c);
            if (result != ErrorCode.SUCCESS)
            {
                throw new OpenCLException("SetArg failed with error code " + result, result);
            }
        }
Esempio n. 5
0
        public void RetainDeviceEXT()
        {
            ErrorCode result;

            result = OpenCL.RetainDeviceEXT(DeviceID);
            if (result != ErrorCode.SUCCESS)
            {
                throw new OpenCLException("RetainDeviceEXT failed with error code: " + result, result);
            }
        }
Esempio n. 6
0
        public void SetArg(int argIndex, Double16 c)
        {
            ErrorCode result;

            result = OpenCL.SetKernelArg(KernelID, (uint)argIndex, (IntPtr)sizeof(Double16), &c);
            if (result != ErrorCode.SUCCESS)
            {
                throw new OpenCLException("SetArg failed with error code " + result, result);
            }
        }
Esempio n. 7
0
        public void SetArg(int argIndex, IntPtr argSize, IntPtr argValue)
        {
            ErrorCode result;

            result = (ErrorCode)OpenCL.SetKernelArg(KernelID, (uint)argIndex, argSize, argValue.ToPointer());
            if (result != ErrorCode.SUCCESS)
            {
                throw new OpenCLException("SetArg failed with error code " + result, result);
            }
        }
Esempio n. 8
0
		static OpenCL() {
			try {
				OpenCL.Initialize();
			}
			catch (Exception) {
				OpenCL._Platforms.Clear();
				OpenCL.PlatformIDs = new IntPtr[0];
				OpenCL.Platforms = new Platform[0];
			}
		}
Esempio n. 9
0
        public override unsafe void ReadProperty(uint key, IntPtr keyLength, void *pBuffer)
        {
            IntPtr    size;
            ErrorCode result;

            result = (ErrorCode)OpenCL.GetImageInfo(MemID, key, keyLength, pBuffer, out size);
            if (result != ErrorCode.SUCCESS)
            {
                base.ReadProperty(key, keyLength, pBuffer);
            }
        }
Esempio n. 10
0
        public void ReadProperty(UInt32 key, IntPtr keyLength, void *pBuffer)
        {
            IntPtr    size;
            ErrorCode result;

            result = OpenCL.GetContextInfo(this.ContextID, key, keyLength, pBuffer, out size);
            if (result != ErrorCode.SUCCESS)
            {
                throw new OpenCLException("GetContextInfo failed: " + result, result);
            }
        }
Esempio n. 11
0
        internal IntPtr ImportFunction(string functionName)
        {
            IntPtr entryPoint;

            entryPoint = OpenCL.GetExtensionFunctionAddressForPlatform(Platform, functionName);
            if (entryPoint == IntPtr.Zero)
            {
                throw new EntryPointNotFoundException("Error when importing function \"" + functionName + "\" from the " + GetName() + " extension");
            }
            return(entryPoint);
        }
Esempio n. 12
0
        public void ReadProperty(UInt32 key, IntPtr keyLength, void *pBuffer)
        {
            IntPtr    size;
            ErrorCode result;

            result = OpenCL.GetDeviceInfo(this.DeviceID, key, keyLength, pBuffer, out size);
            if (result != (Int32)ErrorCode.SUCCESS)
            {
                throw new OpenCLException("Unable to get device info for device " + this.DeviceID, result);
            }
        }
Esempio n. 13
0
        public void ReadProperty(uint key, IntPtr keyLength, void *pBuffer)
        {
            IntPtr    size;
            ErrorCode result;

            result = OpenCL.GetKernelInfo(KernelID, (uint)key, keyLength, pBuffer, out size);
            if (result != (int)ErrorCode.SUCCESS)
            {
                throw new OpenCLException("Unable to get kernel info for kernel " + KernelID, result);
            }
        }
Esempio n. 14
0
        public void ReadProperty(UInt32 key, IntPtr keyLength, void *pBuffer)
        {
            ErrorCode result;
            IntPtr    size;

            result = OpenCL.GetProgramInfo(this.ProgramID, key, keyLength, pBuffer, out size);
            if (result != ErrorCode.SUCCESS)
            {
                throw new OpenCLException("clGetProgramInfo failed with error code " + result, result);
            }
        }
Esempio n. 15
0
        public void ReadProperty(uint key, IntPtr keyLength, void *pBuffer)
        {
            IntPtr    size;
            ErrorCode result;

            result = (ErrorCode)OpenCL.GetDeviceInfo(DeviceID, (uint)key, keyLength, pBuffer, out size);
            if (result != (int)ErrorCode.SUCCESS)
            {
                throw new OpenCLException("Unable to get device info for device " + DeviceID, result);
            }
        }
Esempio n. 16
0
        unsafe public virtual void ReadProperty(uint key, IntPtr keyLength, void *pBuffer)
        {
            IntPtr    size;
            ErrorCode result;

            result = (ErrorCode)OpenCL.GetMemObjectInfo(MemID, key, keyLength, pBuffer, out size);
            if (result != ErrorCode.SUCCESS)
            {
                throw new OpenCLException("GetMemObjectInfo failed: " + result, result);
            }
        }
Esempio n. 17
0
        /// <summary>
        /// OpenCL 1.1
        /// </summary>
        /// <param name="command_exec_callback_type"></param>
        /// <param name="pfn_notify"></param>
        /// <param name="user_data"></param>
        public void SetCallback(ExecutionStatus command_exec_callback_type, EventNotify pfn_notify, object user_data)
        {
            ErrorCode result;
            int       callbackId = AddCallback(this, pfn_notify, user_data);

            result = OpenCL.SetEventCallback(EventID, (int)command_exec_callback_type, CallbackDelegate, (IntPtr)callbackId);
            if (result != ErrorCode.SUCCESS)
            {
                throw new OpenCLException("SetEventCallback failed with error code " + result, result);
            }
        }
Esempio n. 18
0
        public void ReadProperty(uint key, IntPtr keyLength, void *pBuffer)
        {
            ErrorCode result;
            IntPtr    size;

            result = (ErrorCode)OpenCL.GetSamplerInfo(SamplerID, key, keyLength, pBuffer, out size);
            if (result != ErrorCode.SUCCESS)
            {
                throw new OpenCLException("clGetSamplerInfo failed with error code " + result, result);
            }
        }
Esempio n. 19
0
        public void ReadProperty(uint key, IntPtr keyLength, void *pBuffer)
        {
            IntPtr    propertySize;
            ErrorCode result;

            result = (ErrorCode)OpenCL.GetPlatformInfo(PlatformID, key, keyLength, (void *)pBuffer, out propertySize);
            if (result != ErrorCode.SUCCESS)
            {
                throw new OpenCLException("Unable to get platform info for platform " + PlatformID + ": " + result, result);
            }
        }
Esempio n. 20
0
        /// <summary>
        /// Returns the specified profiling counter
        /// </summary>
        /// <param name="paramName"></param>
        /// <param name="paramValue"></param>
        public unsafe void GetEventProfilingInfo(ProfilingInfo paramName, out ulong paramValue)
        {
            IntPtr paramValueSizeRet;
            ulong v;
            ErrorCode errorCode;

            errorCode = OpenCL.GetEventProfilingInfo(EventID, paramName, (IntPtr)sizeof(ulong), &v, out paramValueSizeRet);
            if (errorCode != ErrorCode.SUCCESS)
                throw new OpenCLException("GetEventProfilingInfo failed with error code "+errorCode, errorCode );
            paramValue = v;
        }
Esempio n. 21
0
        public override void ReadProperty(UInt32 key, IntPtr keyLength, void *pBuffer)
        {
            IntPtr    size;
            ErrorCode result;

            result = OpenCL.GetImageInfo(this.MemID, key, keyLength, pBuffer, out size);
            if (result != ErrorCode.SUCCESS)
            {
                base.ReadProperty(key, keyLength, pBuffer);
            }
        }
Esempio n. 22
0
        /// <summary>
        /// Set argument argIndex to c
        /// </summary>
        /// <param name="argIndex"></param>
        /// <param name="c"></param>
        public void SetArg(int argIndex, IntPtr c)
        {
            ErrorCode result;
            IntPtr    lc = c;

            result = (ErrorCode)OpenCL.SetKernelArg(KernelID, (uint)argIndex, (IntPtr)sizeof(IntPtr), &lc);
            if (result != ErrorCode.SUCCESS)
            {
                throw new OpenCLException("SetArg failed with error code " + result, result);
            }
        }
Esempio n. 23
0
        public IntPtr GetPropertySize(uint key)
        {
            IntPtr    size;
            ErrorCode result;

            result = (ErrorCode)OpenCL.GetDeviceInfo(DeviceID, key, IntPtr.Zero, null, out size);
            if (result != ErrorCode.SUCCESS)
            {
                throw new OpenCLException("Unable to get device info for device " + DeviceID, result);
            }
            return(size);
        }
Esempio n. 24
0
        unsafe public virtual IntPtr GetPropertySize(uint key)
        {
            IntPtr    size;
            ErrorCode result;

            result = (ErrorCode)OpenCL.GetMemObjectInfo(MemID, key, IntPtr.Zero, null, out size);
            if (result != ErrorCode.SUCCESS)
            {
                throw new OpenCLException("GetMemObjectInfo failed: " + result, result);
            }
            return(size);
        }
Esempio n. 25
0
        public IntPtr GetPropertySize(uint key)
        {
            IntPtr    propertySize;
            ErrorCode result;

            result = (ErrorCode)OpenCL.GetPlatformInfo(PlatformID, key, IntPtr.Zero, null, out propertySize);
            if (result != ErrorCode.SUCCESS)
            {
                throw new OpenCLException("Unable to get platform info for platform " + PlatformID + ": " + result, result);
            }
            return(propertySize);
        }
Esempio n. 26
0
        public IntPtr GetPropertySize(uint key)
        {
            IntPtr    size;
            ErrorCode result;

            result = (ErrorCode)OpenCL.GetKernelInfo(KernelID, key, IntPtr.Zero, null, out size);
            if (result != ErrorCode.SUCCESS)
            {
                throw new OpenCLException("Unable to get kernel info for kernel " + KernelID, result);
            }
            return(size);
        }
Esempio n. 27
0
            public IntPtr GetPropertySize(uint key)
            {
                IntPtr    size;
                ErrorCode result = OpenCL.GetProgramBuildInfo(Program.ProgramID, Device.DeviceID, key, IntPtr.Zero, null, out size);;

                if (result != ErrorCode.SUCCESS)
                {
                    throw new OpenCLException("clGetProgramBuildInfo failed with error code " + result, result);
                }

                return(size);
            }
Esempio n. 28
0
        public Kernel CreateKernel(string kernelName)
        {
            IntPtr    kernelID;
            ErrorCode result;

            kernelID = OpenCL.CreateKernel(ProgramID, kernelName, out result);
            if (result != ErrorCode.SUCCESS)
            {
                throw new OpenCLException("CreateKernel failed with error code " + result, result);
            }
            return(new Kernel(Context, this, kernelID));
        }
Esempio n. 29
0
        // Override the IPropertyContainer interface of the Mem class.

        #region IPropertyContainer Members
        public override IntPtr GetPropertySize(UInt32 key)
        {
            IntPtr    size;
            ErrorCode result;

            result = OpenCL.GetImageInfo(this.MemID, key, IntPtr.Zero, null, out size);
            if (result != ErrorCode.SUCCESS)
            {
                size = base.GetPropertySize(key);
            }
            return(size);
        }
Esempio n. 30
0
        /// <summary>
        /// OpenCL 1.1
        /// </summary>
        /// <returns></returns>
        public Event CreateUserEvent()
        {
            ErrorCode result;
            IntPtr    eventID;

            eventID = OpenCL.CreateUserEvent(ContextID, out result);
            if (result != ErrorCode.SUCCESS)
            {
                throw new OpenCLException("CreateUserEvent failed with error code " + result, result);
            }
            return(new Event(this, null, eventID));
        }