public void GenerateUniform(CudaDeviceVector deviceVector) { if (deviceVector == null) { throw new ArgumentNullException("deviceVector"); } CudaRandomImports.CurandGenerateUniform(this.generator.Value, deviceVector.DevicePointer, deviceVector.Length); }
public void ScalarMultiplication(CudaDeviceVector deviceVector, CudaHostScalar scalar) { if (deviceVector == null) { throw new ArgumentNullException("deviceVector"); } if (scalar == null) { throw new ArgumentNullException("scalar"); } CudaAlgebraImports.CublasScalarMult(this.handle.Value, deviceVector.DevicePointer, deviceVector.ElementSpacing, deviceVector.Length, scalar.PageLockedPointer); }
public void Copy(CudaDeviceVector deviceVector, CudaHostVector hostVector) { if (hostVector == null) { throw new ArgumentNullException("hostVector"); } if (deviceVector == null) { throw new ArgumentNullException("deviceVector"); } if (hostVector.Length != deviceVector.Length) { throw new ArgumentException("Vector lengths should be equal."); } CudaMemoryImports.CudaGetVector(hostVector.Length, sizeof(float), deviceVector.DevicePointer, deviceVector.ElementSpacing, hostVector.PageLockedPointer, hostVector.ElementSpacing, this.stream.StreamId.Value); }
public void GenerateUniformTest() { using (CudaSharpStream stream = new CudaSharpStream()) { CudaRandom target = stream.Random; using (CudaDeviceVector deviceVector = new CudaDeviceVector(100000)) { using (CudaHostVector hostVector = new CudaHostVector(100000)) { target.GenerateUniform(deviceVector); stream.MemoryManagement.Copy(deviceVector, hostVector); stream.Synchronize(); Assert.IsTrue(hostVector[100] > 0); } } } }
public void CopyVectorTest() { using (CudaSharpStream str = new CudaSharpStream()) { CudaMemoryManagement target = str.MemoryManagement; using (CudaDeviceVector deviceVector = new CudaDeviceVector(5)) { using (CudaHostVector hostVector = new CudaHostVector(5)) { hostVector[2] = 3; using (CudaHostVector hostVector2 = new CudaHostVector(5)) { target.Copy(hostVector, deviceVector); target.Copy(deviceVector, hostVector2); str.Synchronize(); Assert.AreEqual(3, hostVector2[2]); } } } } }
public void ScalarMultiplicationTest() { using (CudaSharpStream stream = new CudaSharpStream()) { CudaAlgebra target = stream.Algebra; using (CudaHostVector hostVector = new CudaHostVector(50000)) { using (CudaDeviceVector deviceVector = new CudaDeviceVector(50000)) { using (CudaHostScalar hostScalar = new CudaHostScalar(3)) { hostVector[2] = 3; stream.MemoryManagement.Copy(hostVector, deviceVector); target.ScalarMultiplication(deviceVector, hostScalar); stream.MemoryManagement.Copy(deviceVector, hostVector); stream.Synchronize(); Assert.AreEqual(9, hostVector[2]); } } } } }