Esempio n. 1
0
        public void SetDestructorCallback(Action <Image, object> notify, object user_data)
        {
            ClHelper.ThrowNullException(Handle);

            if (notify == null)
            {
                throw new ArgumentNullException("notify");
            }

            unsafe
            {
                var function_ptr = IntPtr.Zero;
                var data         = Tuple.Create(notify, user_data);
                var data_handle  = GCHandle.Alloc(data);

                function_ptr = Marshal.GetFunctionPointerForDelegate(new CallbackDelegete(Callback));

                try
                {
                    ClHelper.GetError(Cl.SetMemObjectDestructorCallback(
                                          Handle, function_ptr, GCHandle.ToIntPtr(data_handle).ToPointer()));
                }
                catch (EntryPointNotFoundException)
                {
                    data_handle.Free();
                    throw ClHelper.VersionException(1, 1);
                }
                catch (Exception)
                {
                    data_handle.Free();
                    throw;
                }
            }
        }
Esempio n. 2
0
        public Event EnqueueBarrier(Event[] events)
        {
            ClHelper.ThrowNullException(Handle);

            try
            {
                unsafe
                {
                    int     num_events_in_wait_list = events == null ? 0 : events.Length;
                    IntPtr *wait_list = stackalloc IntPtr[num_events_in_wait_list];
                    for (int i = 0; i < num_events_in_wait_list; ++i)
                    {
                        wait_list[i] = events[i].Handle;
                    }
                    if (events == null)
                    {
                        wait_list = null;
                    }

                    IntPtr event_ptr = IntPtr.Zero;

                    ClHelper.GetError(Cl.EnqueueBarrierWithWaitList(
                                          Handle, (uint)num_events_in_wait_list, wait_list, &event_ptr));

                    return(new Event(event_ptr));
                }
            }
            catch (EntryPointNotFoundException)
            {
                throw ClHelper.VersionException(1, 2);
            }
        }
Esempio n. 3
0
        public void SetUserEventStatus(int status)
        {
            ClHelper.ThrowNullException(Handle);

            if (status > 0)
            {
                throw new ArgumentException("status must be zero or negative.");
            }

            try
            {
                ClHelper.GetError(Cl.SetUserEventStatus(Handle, status));
            }
            catch (EntryPointNotFoundException)
            {
                throw ClHelper.VersionException(1, 1);
            }
        }
Esempio n. 4
0
        public Event(Context context)
            : this()
        {
            if (context == Context.Null)
            {
                throw new ArgumentNullException("context");
            }

            try
            {
                unsafe
                {
                    int error;
                    Handle = Cl.CreateUserEvent(context.Handle, &error);
                    ClHelper.GetError(error);
                }
            }
            catch (EntryPointNotFoundException)
            {
                throw ClHelper.VersionException(1, 1);
            }
        }