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]); } } } } }