/// <summary> /// Sets the parameters for a memset node in the given graphExec.<para/> /// Updates the work represented by \p hNode in \p hGraphExec as though \p hNode had /// contained \p memsetParams 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 destination memory in \p memsetParams must be allocated from the same /// contexts as the original destination memory. Both the instantiation-time /// memory operand and the memory operand in \p memsetParams must be 1-dimensional. /// Zero-length operations are not supported.<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.<para/> /// Returns CUDA_ERROR_INVALID_VALUE if the memory operand's mappings changed or /// either the original or new memory operand are multidimensional. /// </summary> public void SetParams(CUgraphNode hNode, ref CudaMemsetNodeParams memsetParams, CUcontext ctx) { res = DriverAPINativeMethods.GraphManagment.cuGraphExecMemsetNodeSetParams(_graph, hNode, ref memsetParams, ctx); Debug.WriteLine(String.Format("{0:G}, {1}: {2}", DateTime.Now, "cuGraphExecMemsetNodeSetParams", res)); if (res != CUResult.Success) { throw new CudaException(res); } }
/// <summary> /// Gets the parameters of memset node. /// </summary> /// <param name="nodeParams"></param> public void GetParameters(ref CudaMemsetNodeParams nodeParams) { CUResult res = DriverAPINativeMethods.GraphManagment.cuGraphMemsetNodeGetParams(this, ref nodeParams); Debug.WriteLine(String.Format("{0:G}, {1}: {2}", DateTime.Now, "cuGraphMemsetNodeGetParams", res)); if (res != CUResult.Success) { throw new CudaException(res); } }
/// <summary> /// Creates a memset node and adds it to a graph<para/> /// Creates a new memset node and adds it to graph with /// dependencies specified via dependencies.<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/> /// The element size must be 1, 2, or 4 bytes.<para/> /// When the graph is launched, the node will perform the memset described by memsetParams. /// </summary> /// <param name="dependencies">can be null</param> /// <param name="memsetParams">When the graph is launched, the node will perform the memset described by memsetParams.</param> /// <param name="ctx">Cuda context used for the operation</param> /// <returns>A handle to the new node will be returned.</returns> public CUgraphNode AddMemsetNode(CUgraphNode[] dependencies, CudaMemsetNodeParams memsetParams, CudaContext ctx) { CUgraphNode node = new CUgraphNode(); SizeT numDependencies = 0; if (dependencies != null) { numDependencies = dependencies.Length; } res = DriverAPINativeMethods.GraphManagment.cuGraphAddMemsetNode(ref node, _graph, dependencies, numDependencies, ref memsetParams, ctx.Context); Debug.WriteLine(String.Format("{0:G}, {1}: {2}", DateTime.Now, "cuGraphAddMemsetNode", res)); if (res != CUResult.Success) { throw new CudaException(res); } return(node); }
/// <summary> /// Creates a memset node and adds it to a graph<para/> /// Creates a new memset node and adds it to graph with /// dependencies specified via dependencies.<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/> /// The element size must be 1, 2, or 4 bytes.<para/> /// When the graph is launched, the node will perform the memset described by memsetParams. /// </summary> /// <param name="dependencies">can be null</param> /// <param name="deviceVariable">When the graph is launched, the node will perform the memset on deviceVariable.</param> /// <param name="value">Value to set</param> /// <param name="ctx">Cuda context used for the operation</param> /// <returns>A handle to the new node will be returned.</returns> public CUgraphNode AddMemsetNode <T>(CUgraphNode[] dependencies, CudaPitchedDeviceVariable <T> deviceVariable, uint value, CudaContext ctx) where T : struct { CUgraphNode node = new CUgraphNode(); SizeT numDependencies = 0; if (dependencies != null) { numDependencies = dependencies.Length; } CudaMemsetNodeParams memsetParams = CudaMemsetNodeParams.init <T>(deviceVariable, value); res = DriverAPINativeMethods.GraphManagment.cuGraphAddMemsetNode(ref node, _graph, dependencies, numDependencies, ref memsetParams, ctx.Context); Debug.WriteLine(String.Format("{0:G}, {1}: {2}", DateTime.Now, "cuGraphAddMemsetNode", res)); if (res != CUResult.Success) { throw new CudaException(res); } return(node); }