コード例 #1
0
        public void ClearOnDevice()
        {
            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);

            // Copy to device
            storage.CopyToDevice();

            //Clear
            storage.Clear();

            // Copy back to host
            storage.CopyToHost();
            Assert.IsTrue(storage.ToArray().All(o => o == 0.0));
        }
コード例 #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);
        }