Ejemplo n.º 1
0
        /// <summary>
        /// Creates a host execution node and adds it to a graph<para/>
        /// Creates a new CPU execution node and adds it to the graph with
        /// dependencies specified via dependencies.
        /// 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.
        /// A handle to the new node will be returned.<para/>
        /// When the graph is launched, the node will invoke the specified CPU function.
        /// </summary>
        /// <param name="dependencies">can be null</param>
        /// <param name="hostFunction">Host function to execute</param>
        /// <param name="userData">User data for host function. Note that the data object must be pinned by GC!</param>
        /// <returns>A handle to the new node will be returned.</returns>
        public CUgraphNode AddHostNode(CUgraphNode[] dependencies, CUhostFn hostFunction, IntPtr userData)
        {
            CUgraphNode node            = new CUgraphNode();
            SizeT       numDependencies = 0;

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

            CudaHostNodeParams nodeParams = new CudaHostNodeParams
            {
                fn       = hostFunction,
                userData = userData
            };

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

            return(node);
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Sets the parameters for a host node in the given graphExec.<para/>
 /// Updates the work represented by \p hNode in \p hGraphExec as though \p hNode had
 /// contained \p nodeParams at instantiation.  hNode must remain in the graph which was
 /// used to instantiate \p hGraphExec.  Changed edges to and from hNode are ignored.<para/>
 /// The modifications only affect future launches of \p hGraphExec.  Already enqueued
 /// or running launches of \p hGraphExec are not affected by this call.  hNode is also
 /// not modified by this call.
 /// </summary>
 public void SetParams(CUgraphNode hNode, ref CudaHostNodeParams nodeParams)
 {
     res = DriverAPINativeMethods.GraphManagment.cuGraphExecHostNodeSetParams(_graph, hNode, ref nodeParams);
     Debug.WriteLine(String.Format("{0:G}, {1}: {2}", DateTime.Now, "cuGraphExecHostNodeSetParams", res));
     if (res != CUResult.Success)
     {
         throw new CudaException(res);
     }
 }
        /// <summary>
        /// Gets the parameters of host node.
        /// </summary>
        /// <param name="nodeParams"></param>
        public void GetParameters(ref CudaHostNodeParams nodeParams)
        {
            CUResult res = DriverAPINativeMethods.GraphManagment.cuGraphHostNodeGetParams(this, ref nodeParams);

            Debug.WriteLine(String.Format("{0:G}, {1}: {2}", DateTime.Now, "cuGraphHostNodeGetParams", res));
            if (res != CUResult.Success)
            {
                throw new CudaException(res);
            }
        }