public static KernelResult Run(this JittedFunction function, dim3 gridDim, dim3 blockDim, IEnumerable<KernelArgument> args) { function.AssertNotNull(); args = args ?? Seq.Empty<KernelArgument>().ToArray(); CudaDriver.Ensure(); var invocation = new KernelInvocation(function, args); return invocation.Launch(gridDim, blockDim); }
internal void PassInto(KernelInvocation invocation, int offset) { if (_type.IsCudaPrimitive()) { if (_type.IsInteger()) { (_type == typeof(int) || _type == typeof(uint)).AssertTrue(); (Direction == ParameterDirection.In).AssertTrue(); var value = _value.AssertCoerce <uint>(); nvcuda.cuParamSeti(invocation.Function.Handle, offset, value); } else if (_type.IsFloatingPoint()) { (_type == typeof(float)).AssertTrue(); (Direction == ParameterDirection.In).AssertTrue(); var value = _value.AssertCoerce <float>(); nvcuda.cuParamSetf(invocation.Function.Handle, offset, value); } else { throw AssertionHelper.Fail(); } } else if (_type.IsCudaVector()) { (Direction == ParameterDirection.In).AssertTrue(); nvcuda.cuParamSetv(invocation.Function.Handle, offset, _value); } else { if (_type.IsValueType) { (Direction == ParameterDirection.In).AssertTrue(); nvcuda.cuParamSetv(invocation.Function.Handle, offset, _value); } else if (_type.IsClass) { if (_value.IsArray()) { nvcuda.cuParamSeti(invocation.Function.Handle, offset, _devicePtr); } else { throw AssertionHelper.Fail(); } } } }
internal void PassInto(KernelInvocation invocation, int offset) { if (_type.IsCudaPrimitive()) { if (_type.IsInteger()) { (_type == typeof(int) || _type == typeof(uint)).AssertTrue(); (Direction == ParameterDirection.In).AssertTrue(); var value = _value.AssertCoerce<uint>(); nvcuda.cuParamSeti(invocation.Function.Handle, offset, value); } else if (_type.IsFloatingPoint()) { (_type == typeof(float)).AssertTrue(); (Direction == ParameterDirection.In).AssertTrue(); var value = _value.AssertCoerce<float>(); nvcuda.cuParamSetf(invocation.Function.Handle, offset, value); } else { throw AssertionHelper.Fail(); } } else if (_type.IsCudaVector()) { (Direction == ParameterDirection.In).AssertTrue(); nvcuda.cuParamSetv(invocation.Function.Handle, offset, _value); } else { if (_type.IsValueType) { (Direction == ParameterDirection.In).AssertTrue(); nvcuda.cuParamSetv(invocation.Function.Handle, offset, _value); } else if (_type.IsClass) { if (_value.IsArray()) { nvcuda.cuParamSeti(invocation.Function.Handle, offset, _devicePtr); } else { throw AssertionHelper.Fail(); } } } }
internal KernelResult(KernelInvocation invocation, ElapsedTime wallTime) { _invocation = invocation; WallTime = wallTime; }
internal KernelResult(KernelInvocation invocation) { _invocation = invocation; }
public KernelResult Run(dim3 gridDim, dim3 blockDim, IEnumerable<KernelArgument> args) { var invocation = new KernelInvocation(this, args); return invocation.Launch(gridDim, blockDim); }
public static Object Invoke(this JittedFunction function, dim3 gridDim, dim3 blockDim, IEnumerable<KernelArgument> args) { function.AssertNotNull(); args = args ?? Seq.Empty<KernelArgument>().ToArray(); CudaDriver.Ensure(); var invocation = new KernelInvocation(function, args); var invocation_result = invocation.Launch(gridDim, blockDim); var result = invocation_result.Result; args.ForEach(arg => arg.Dispose()); return result; }