Esempio n. 1
0
        /// <summary>
        /// Creates a kernel execution node and adds it to a graph<para/>
        /// Creates a new kernel execution node and adds it to the graph with
        /// dependencies specified via dependencies and arguments specified in nodeParams.<para/>
        /// It is possible for dependencies to be null, in which case the node will be placed
        /// at the root of the graph. Dependencies may not have any duplicate entries.<para/>
        /// A handle to the new node will be returned.
        /// </summary>
        /// <param name="dependencies">can be null</param>
        /// <param name="nodeParams">Parameters for the GPU execution node</param>
        /// <returns>A handle to the new node will be returned.</returns>
        public CUgraphNode AddKernelNode(CUgraphNode[] dependencies, CUDA_KERNEL_NODE_PARAMS nodeParams)
        {
            CUgraphNode node            = new CUgraphNode();
            SizeT       numDependencies = 0;

            if (dependencies != null)
            {
                numDependencies = dependencies.Length;
            }

            res = DriverAPINativeMethods.GraphManagment.cuGraphAddKernelNode(ref node, _graph, dependencies, numDependencies, ref nodeParams);
            Debug.WriteLine(String.Format("{0:G}, {1}: {2}", DateTime.Now, "cuGraphAddKernelNode", res));
            if (res != CUResult.Success)
            {
                throw new CudaException(res);
            }

            return(node);
        }
Esempio n. 2
0
        /// <summary>
        /// Creates a kernel execution node and adds it to a graph<para/>
        /// Creates a new kernel execution node and adds it to the graph with
        /// dependencies specified via dependencies and arguments specified in nodeParams.<para/>
        /// It is possible for dependencies to be null, in which case the node will be placed
        /// at the root of the graph. Dependencies may not have any duplicate entries.<para/>
        /// A handle to the new node will be returned.
        /// </summary>
        /// <param name="dependencies">can be null</param>
        /// <param name="kernel">Kernel to execute</param>
        /// <param name="parameters">Kernel parameters to pass. An Array of IntPtr each of them pointing to a parameters. Note that the parameters must be pinned by GC!</param>
        /// <param name="extras">Extra data</param>
        /// <returns>A handle to the new node will be returned.</returns>
        public CUgraphNode AddKernelNode(CUgraphNode[] dependencies, CudaKernel kernel, IntPtr parameters, IntPtr extras)
        {
            CUgraphNode node            = new CUgraphNode();
            SizeT       numDependencies = 0;

            if (dependencies != null)
            {
                numDependencies = dependencies.Length;
            }

            CUDA_KERNEL_NODE_PARAMS nodeParams = new CUDA_KERNEL_NODE_PARAMS
            {
                blockDimX = kernel.BlockDimensions.x,
                blockDimY = kernel.BlockDimensions.y,
                blockDimZ = kernel.BlockDimensions.z,

                extra = extras,
                func  = kernel.CUFunction,

                gridDimX = kernel.GridDimensions.x,
                gridDimY = kernel.GridDimensions.y,
                gridDimZ = kernel.GridDimensions.z,

                kernelParams   = parameters,
                sharedMemBytes = kernel.DynamicSharedMemory
            };

            res = DriverAPINativeMethods.GraphManagment.cuGraphAddKernelNode(ref node, _graph, dependencies, numDependencies, ref nodeParams);
            Debug.WriteLine(String.Format("{0:G}, {1}: {2}", DateTime.Now, "cuGraphAddKernelNode", res));
            if (res != CUResult.Success)
            {
                throw new CudaException(res);
            }

            return(node);
        }