Ejemplo n.º 1
0
 public static extern CLError GetKernelWorkGroupInfo(
     [In] IntPtr kernel,
     [In] IntPtr device,
     [In] CLKernelWorkGroupInfoType workGroupInfoType,
     [In] IntPtr maxSize,
     [Out] void *paramValue,
     [Out] IntPtr size);
Ejemplo n.º 2
0
        /// <summary>
        /// Resolves kernel work-group information as typed structure value of type <typeparamref name="T"/>
        /// </summary>
        /// <typeparam name="T">The target type.</typeparam>
        /// <param name="kernel">The kernel.</param>
        /// <param name="device">The device.</param>
        /// <param name="type">The information type.</param>
        /// <returns>The resolved value.</returns>
        public static T GetKernelWorkGroupInfo <T>(
            IntPtr kernel,
            IntPtr device,
            CLKernelWorkGroupInfoType type)
            where T : struct
        {
            T value = default;

            CLException.ThrowIfFailed(NativeMethods.GetKernelWorkGroupInfo(
                                          kernel,
                                          device,
                                          type,
                                          new IntPtr(Interop.SizeOf <T>()),
                                          Unsafe.AsPointer(ref value),
                                          IntPtr.Zero));
            return(value);
        }
Ejemplo n.º 3
0
 /// <summary>
 /// Resolves kernel work-group information as typed array of values of type
 /// <typeparamref name="T"/>.
 /// </summary>
 /// <typeparam name="T">The target type.</typeparam>
 /// <param name="kernel">The kernel.</param>
 /// <param name="device">The device.</param>
 /// <param name="type">The information type.</param>
 /// <param name="elements">The desired elements.</param>
 public static void GetKernelWorkGroupInfo <T>(
     IntPtr kernel,
     IntPtr device,
     CLKernelWorkGroupInfoType type,
     T[] elements)
     where T : unmanaged
 {
     fixed(T *ptr = &elements[0])
     {
         CLException.ThrowIfFailed(NativeMethods.GetKernelWorkGroupInfo(
                                       kernel,
                                       device,
                                       type,
                                       new IntPtr(Interop.SizeOf <T>() * elements.Length),
                                       ptr,
                                       IntPtr.Zero));
     }
 }
Ejemplo n.º 4
0
        /// <summary>
        /// Resolves kernel work-group information as typed array of values of type <typeparamref name="T"/>.
        /// </summary>
        /// <typeparam name="T">The target type.</typeparam>
        /// <param name="kernel">The kernel.</param>
        /// <param name="device">The device.</param>
        /// <param name="type">The information type.</param>
        /// <param name="elements">The desired elements.</param>
        public static void GetKernelWorkGroupInfo <T>(
            IntPtr kernel,
            IntPtr device,
            CLKernelWorkGroupInfoType type,
            T[] elements)
            where T : struct
        {
            var handle = GCHandle.Alloc(elements, GCHandleType.Pinned);

            try
            {
                CLException.ThrowIfFailed(NativeMethods.GetKernelWorkGroupInfo(
                                              kernel,
                                              device,
                                              type,
                                              new IntPtr(Interop.SizeOf <T>() * elements.Length),
                                              handle.AddrOfPinnedObject().ToPointer(),
                                              IntPtr.Zero));
            }
            finally
            {
                handle.Free();
            }
        }