示例#1
0
 def test_array_sizes_3d(self):
     k = KernelCode(self.threed_code, machine=None)
     k.set_constant('N', 10)
     k.set_constant('M', 20)
     sizes = k.array_sizes(in_bytes=True, subs_consts=True)
     # 8 byte per double
     checked_sizes = {'a': 20 * 10 * 10 * 8, 'b': 20 * 10 * 10 * 8}
     self.assertEqual(sizes, checked_sizes)
示例#2
0
 def test_array_sizes_3d(self):
     k = KernelCode(self.threed_code)
     k.set_constant('N', 10)
     k.set_constant('M', 20)
     sizes = k.array_sizes(in_bytes=True, subs_consts=True)
     # 8 byte per double
     checked_sizes = {'a': 20*10*10*8, 'b': 20*10*10*8}
     self.assertEqual(sizes, checked_sizes)
示例#3
0
 def test_global_offsets_2d(self):
     k = KernelCode(self.twod_code, machine=None)
     k.set_constant('N', 10)
     k.set_constant('M', 20)
     sizes = k.array_sizes(in_bytes=True, subs_consts=True)
     offsets = k.compile_global_offsets(iteration=0, spacing=0)
     read_offsets, write_offsets = list(offsets)[0]
     # read access to a[j][i-1], a[j][i+1], a[j-1][i], a[j+1][i]
     self.assertCountEqual([(1 * 10 + 0) * 8, (1 * 10 + 2) * 8,
                            (0 * 10 + 1) * 8, (2 * 10 + 1) * 8],
                           read_offsets)
     # write access to b[i][j]
     self.assertCountEqual([sizes['a'] + (1 * 10 + 1) * 8], write_offsets)
示例#4
0
 def test_global_offsets_2d(self):
     k = KernelCode(self.twod_code, machine=None)
     k.set_constant('N', 10)
     k.set_constant('M', 20)
     sizes = k.array_sizes(in_bytes=True, subs_consts=True)
     offsets = k.compile_global_offsets(iteration=0, spacing=0)
     read_offsets, write_offsets = list(offsets)[0]
     # read access to a[j][i-1], a[j][i+1], a[j-1][i], a[j+1][i]
     self.assertCountEqual(
         [(1 * 10 + 0) * 8, (1 * 10 + 2) * 8, (0 * 10 + 1) * 8, (2 * 10 + 1) * 8],
         read_offsets)
     # write access to b[i][j]
     self.assertCountEqual(
         [sizes['a'] + (1 * 10 + 1) * 8],
         write_offsets)