Example #1
0
 /// <summary>
 /// Sets the parameters for a kernel node in the given graphExec<para/>
 /// Sets the parameters of a kernel node in an executable graph \p hGraphExec.
 /// The node is identified by the corresponding node \p hNode in the
 /// non-executable graph, from which the executable graph was instantiated.<para/>
 /// \p hNode must not have been removed from the original graph.The \p func field
 /// of \p nodeParams cannot be modified and must match the original value.
 /// All other values can be modified.<para/>
 /// The modifications only affect future launches of \p hGraphExec. Already
 /// enqueued or running launches of \p hGraphExec are not affected by this call.
 /// \p hNode is also not modified by this call.
 /// </summary>
 /// <param name="hNode"></param>
 /// <param name="nodeParams"></param>
 public void SetParams(CUgraphNode hNode, ref CudaKernelNodeParams nodeParams)
 {
     res = DriverAPINativeMethods.GraphManagment.cuGraphExecKernelNodeSetParams(_graph, hNode, ref nodeParams);
     Debug.WriteLine(String.Format("{0:G}, {1}: {2}", DateTime.Now, "cuGraphExecKernelNodeSetParams", res));
     if (res != CUResult.Success)
     {
         throw new CudaException(res);
     }
 }
        /// <summary>
        /// Gets the parameters of kernel node.
        /// </summary>
        /// <param name="nodeParams"></param>
        public void GetParameters(ref CudaKernelNodeParams nodeParams)
        {
            CUResult res = DriverAPINativeMethods.GraphManagment.cuGraphKernelNodeGetParams(this, ref nodeParams);

            Debug.WriteLine(String.Format("{0:G}, {1}: {2}", DateTime.Now, "cuGraphKernelNodeGetParams", res));
            if (res != CUResult.Success)
            {
                throw new CudaException(res);
            }
        }
Example #3
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, CudaKernelNodeParams 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);
        }
Example #4
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;
            }

            CudaKernelNodeParams nodeParams = new CudaKernelNodeParams
            {
                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);
        }