コード例 #1
0
        public void ReadPartTest()
        {
            using (var mem = new StructMappingMemory <MyMappingStruct>(Context, 100))
            {
                MyMappingStruct[] dat = Enumerable.Range(0, 100)
                                        .Select(n => new MyMappingStruct()
                {
                    X = n, Y = n + 10, Point = n * 2.2f
                })
                                        .ToArray();
                MyMappingStruct[] ans = new MyMappingStruct[25];

                mem.Write(CommandQueue, true, 0, dat.Length, dat).Wait();

                mem.Read(CommandQueue, true, 0, 25, ans).Wait();
                Assert.AreEqual(dat.Skip(0).Take(25), ans);

                mem.Read(CommandQueue, true, 25, 25, ans).Wait();
                Assert.AreEqual(dat.Skip(25).Take(25), ans);

                mem.Read(CommandQueue, true, 50, 25, ans).Wait();
                Assert.AreEqual(dat.Skip(50).Take(25), ans);

                mem.Read(CommandQueue, true, 75, 25, ans).Wait();
                Assert.AreEqual(dat.Skip(75).Take(25), ans);
            }
        }
コード例 #2
0
        public void MappingTest()
        {
            MyMappingStruct[] dat = Enumerable.Range(0, 100)
                                    .Select(n => new MyMappingStruct()
            {
                X = n, Y = n + 10, Point = n * 2.2f
            })
                                    .ToArray();
            MyMappingStruct[] ans = new MyMappingStruct[100];

            using (var mem = new StructMappingMemory <MyMappingStruct>(Context, 100))
            {
                using (var map = mem.Mapping(CommandQueue, true, 0, 100))
                {
                    for (int i = 0; i < 100; ++i)
                    {
                        map[i] = new MyMappingStruct()
                        {
                            X = i, Y = i + 10, Point = i * 2.2f
                        };
                    }
                }

                mem.Read(CommandQueue, true, ans);
                Assert.AreEqual(dat, ans);
            }
        }
コード例 #3
0
        public void ReadWriteTest()
        {
            using (var mem = new StructMappingMemory <MyMappingStruct>(Context, 100))
            {
                MyMappingStruct[] dat = Enumerable.Range(0, 100)
                                        .Select(n => new MyMappingStruct()
                {
                    X = n, Y = n + 10, Point = n * 2.2f
                })
                                        .ToArray();
                MyMappingStruct[] ans = new MyMappingStruct[100];

                mem.WriteDirect(CommandQueue, true, 0, dat.Length, dat, 0).Wait();
                mem.ReadDirect(CommandQueue, true, 0, ans.Length, ans, 0).Wait();
                Assert.AreEqual(dat, ans);


                mem.Write(CommandQueue, true, 0, dat.Length, dat, 0).Wait();
                Assert.AreEqual(dat, ans);

                mem.Write(CommandQueue, true, 0, dat.Length, dat).Wait();
                Assert.AreEqual(dat, ans);

                mem.Write(CommandQueue, true, dat.Length, dat).Wait();
                Assert.AreEqual(dat, ans);

                mem.Write(CommandQueue, true, dat).Wait();
                Assert.AreEqual(dat, ans);



                mem.Read(CommandQueue, true, 0, ans.Length, ans, 0).Wait();
                Assert.AreEqual(dat, ans);

                mem.Read(CommandQueue, true, 0, ans.Length, ans).Wait();
                Assert.AreEqual(dat, ans);

                mem.Read(CommandQueue, true, ans.Length, ans).Wait();
                Assert.AreEqual(dat, ans);

                mem.Read(CommandQueue, true, ans).Wait();
                Assert.AreEqual(dat, ans);
            }
        }