Ejemplo n.º 1
0
        public void ClearOnHost()
        {
            const int l       = 4080;
            var       shape   = new Shape(l);
            var       data    = new double[l].Populate(1.0);
            var       storage = new VolumeStorage(data, shape, GpuContext.Default);

            //Clear
            storage.Clear();

            // Copy back to host
            storage.CopyToHost();
            Assert.IsTrue(storage.ToArray().All(o => o == 0.0));
        }
Ejemplo n.º 2
0
        public void CopyToHostAndDevice()
        {
            const int l       = 4080;
            var       shape   = new Shape(l);
            var       data    = new double[l].Populate(1.0);
            var       storage = new VolumeStorage(data, shape, GpuContext.Default);

            Assert.IsTrue(data.SequenceEqual(storage.ToArray()));
            Assert.AreEqual(DataLocation.Host, storage.Location);

            // Copy to device
            storage.CopyToDevice();
            Assert.AreEqual(DataLocation.Device, storage.Location);

            // Copy back to host
            storage.CopyToHost();
            Assert.IsTrue(data.SequenceEqual(storage.ToArray()));
            Assert.AreEqual(DataLocation.Host, storage.Location);
        }