Пример #1
0
    def runTest(self):
        ufunc, nx, ny, nz, coeff_use, precision_float, tmax = self.args

        fields = gpu.Fields(0, nx, ny, nz, coeff_use, precision_float)
        gpu.Core(fields)

        fields_ref = naive.Fields(nx,
                                  ny,
                                  nz,
                                  precision_float,
                                  segment_nbytes=64)
        naive.Core(fields_ref)

        # allocations
        ns = fields.ns
        dtype = fields.dtype
        strf_list = ['ex', 'ey', 'ez', 'hx', 'hy', 'hz']

        ehs = common_random.generate_ehs(nx, ny, nz, dtype, ufunc)
        fields.set_eh_bufs(*ehs)
        fields_ref.set_ehs(*ehs)

        ces, chs = common_random.generate_cs(nx, ny, nz, dtype, coeff_use)
        if 'e' in coeff_use:
            fields.set_ce_bufs(*ces)
            fields_ref.set_ces(*ces)
        if 'h' in coeff_use:
            fields.set_ch_bufs(*chs)
            fields_ref.set_chs(*chs)

        tmpf = np.zeros(fields.ns_pitch, dtype=dtype)

        # update
        if ufunc == 'e':
            for tstep in xrange(0, tmax):
                fields.update_e()
                fields_ref.update_e()

            for strf, eh in zip(strf_list, ehs)[:3]:
                cuda.memcpy_dtoh(tmpf, fields.get_buf(strf))
                norm = np.linalg.norm(fields_ref.get(strf) - tmpf)
                max_diff = np.abs(fields_ref.get(strf) - tmpf).max()
                self.assertEqual(
                    norm, 0,
                    '%s, %s, %g, %g' % (self.args, strf, norm, max_diff))

        elif ufunc == 'h':
            for tstep in xrange(0, tmax):
                fields.update_h()
                fields_ref.update_h()

            for strf, eh in zip(strf_list, ehs)[3:]:
                cuda.memcpy_dtoh(tmpf, fields.get_buf(strf))
                norm = np.linalg.norm(fields_ref.get(strf) - tmpf)
                max_diff = np.abs(fields_ref.get(strf) - tmpf).max()
                self.assertEqual(
                    norm, 0,
                    '%s, %s, %g, %g' % (self.args, strf, norm, max_diff))

        fields.context.pop()
    def runTest(self):
        nx, ny, nz, str_f, pt0, pt1 = self.args

        slidx = common.slices_two_points(pt0, pt1)
        str_fs = common.convert_to_tuple(str_f)

        # instance
        gpu_devices = common_gpu.gpu_device_list(print_info=False)
        context = cl.Context(gpu_devices)
        device = gpu_devices[0]
        fields = Fields(context, device, nx, ny, nz, '', 'single')
        getf = GetFields(fields, str_f, pt0, pt1) 
        
        # host allocations
        ehs = common_random.generate_ehs(nx, ny, nz, fields.dtype)
        eh_dict = dict( zip(['ex', 'ey', 'ez', 'hx', 'hy', 'hz'], ehs) )
        fields.set_eh_bufs(*ehs)

        # verify
        getf.get_event().wait()

        for str_f in str_fs:
            original = eh_dict[str_f][slidx]
            copy = getf.get_fields(str_f)
            norm = np.linalg.norm(original - copy)
            self.assertEqual(norm, 0, '%s, %g' % (self.args, norm))
Пример #3
0
    def runTest(self):
        ufunc, nx, ny, nz, coeff_use, precision_float, use_cpu_core, tmax = self.args
        qtask = cpu.QueueTask()
        fields = cpu.Fields(qtask, nx, ny, nz, coeff_use, precision_float,
                            use_cpu_core)
        cpu.Core(fields)

        fields_ref = naive.Fields(nx,
                                  ny,
                                  nz,
                                  precision_float,
                                  segment_nbytes=16)
        naive.Core(fields_ref)

        # allocations
        ns = fields.ns
        dtype = fields.dtype

        ehs = common_random.generate_ehs(nx, ny, nz, dtype, ufunc)
        fields.set_ehs(*ehs)
        fields_ref.set_ehs(*ehs)

        ces, chs = common_random.generate_cs(nx, ny, nz, dtype, coeff_use)
        if 'e' in coeff_use:
            fields.set_ces(*ces)
            fields_ref.set_ces(*ces)
        if 'h' in coeff_use:
            fields.set_chs(*chs)
            fields_ref.set_chs(*chs)

        # verify
        strf_list = ['ex', 'ey', 'ez', 'hx', 'hy', 'hz']

        if ufunc == 'e':
            for tstep in xrange(0, tmax):
                fields.update_e()
                fields_ref.update_e()
            fields.enqueue_barrier()

            for strf, eh in zip(strf_list, ehs)[:3]:
                norm = np.linalg.norm(fields.get(strf) - fields_ref.get(strf))
                max_diff = np.abs(fields.get(strf) -
                                  fields_ref.get(strf)).max()
                self.assertEqual(
                    norm, 0,
                    '%s, %s, %g, %g' % (self.args, strf, norm, max_diff))

        elif ufunc == 'h':
            for tstep in xrange(0, tmax):
                fields.update_h()
                fields_ref.update_h()
            fields.enqueue_barrier()

            for strf, eh in zip(strf_list, ehs)[3:]:
                norm = np.linalg.norm(fields.get(strf) - fields_ref.get(strf))
                max_diff = np.abs(fields.get(strf) -
                                  fields_ref.get(strf)).max()
                self.assertEqual(norm, 0, '%s, %s, %g, %g' % \
                        (self.args, strf, norm, max_diff) )
Пример #4
0
    def runTest(self):
        ufunc, nx, ny, nz, coeff_use, precision_float, tmax = self.args

        gpu_devices = common_gpu.gpu_device_list(print_info=False)
        context = cl.Context(gpu_devices)
        device = gpu_devices[0]
        fields = gpu.Fields(context, device, nx, ny, nz, coeff_use,
                            precision_float)
        gpu.Core(fields)

        fields_ref = naive.Fields(nx, ny, nz, precision_float)
        naive.Core(fields_ref)

        # allocations
        ns = fields.ns
        dtype = fields.dtype
        strf_list = ['ex', 'ey', 'ez', 'hx', 'hy', 'hz']

        ehs = common_random.generate_ehs(nx, ny, nz, dtype, ufunc)
        fields.set_eh_bufs(*ehs)
        fields_ref.set_ehs(*ehs)

        ces, chs = common_random.generate_cs(nx, ny, nz, dtype, coeff_use)
        if 'e' in coeff_use:
            fields.set_ce_bufs(*ces)
            fields_ref.set_ces(*ces)
        if 'h' in coeff_use:
            fields.set_ch_bufs(*chs)
            fields_ref.set_chs(*chs)

        tmpf = np.zeros(fields.ns, dtype=dtype)

        # update
        if ufunc == 'e':
            for tstep in xrange(0, tmax):
                fields.update_e()
                fields_ref.update_e()

            for strf, eh in zip(strf_list, ehs)[:3]:
                cl.enqueue_copy(fields.queue, tmpf, fields.get_buf(strf))
                norm = np.linalg.norm(fields_ref.get(strf) - tmpf)
                max_diff = np.abs(fields_ref.get(strf) - tmpf).max()
                self.assertEqual(
                    norm, 0,
                    '%s, %s, %g, %g' % (self.args, strf, norm, max_diff))

        elif ufunc == 'h':
            for tstep in xrange(0, tmax):
                fields.update_h()
                fields_ref.update_h()

            for strf, eh in zip(strf_list, ehs)[3:]:
                cl.enqueue_copy(fields.queue, tmpf, fields.get_buf(strf))
                norm = np.linalg.norm(fields_ref.get(strf) - tmpf)
                max_diff = np.abs(fields_ref.get(strf) - tmpf).max()
                self.assertEqual(
                    norm, 0,
                    '%s, %s, %g, %g' % (self.args, strf, norm, max_diff))
    def runTest(self):
        nx, ny, nz, str_f, pt0, pt1 = self.args

        slices = common.slices_two_points(pt0, pt1)
        str_fs = common.convert_to_tuple(str_f)

        # instance
        gpu_devices = common_gpu.gpu_device_list(print_info=False)
        context = cl.Context(gpu_devices)

        mainf_list = [gpu.Fields(context, device, nx, ny, nz) \
                for device in gpu_devices]
        mainf_list.append( cpu.Fields(nx, ny, nz) )
        nodef = Fields(mainf_list)
        dtype = nodef.dtype
        anx = nodef.accum_nx_list

        getf = GetFields(nodef, str_f, pt0, pt1) 
        
        # generate random source
        global_ehs = [np.zeros(nodef.ns, dtype) for i in range(6)]
        eh_dict = dict( zip(['ex', 'ey', 'ez', 'hx', 'hy', 'hz'], global_ehs) )

        for i, f in enumerate(mainf_list[:-1]):
            nx, ny, nz = f.ns
            ehs = common_random.generate_ehs(nx, ny, nz, dtype)
            f.set_eh_bufs(*ehs)
            for eh, geh in zip(ehs, global_ehs):
                geh[anx[i]:anx[i+1],:,:] = eh[:-1,:,:]

        f = mainf_list[-1]
        nx, ny, nz = f.ns
        ehs = common_random.generate_ehs(nx, ny, nz, dtype)
        f.set_ehs(*ehs)
        for eh, geh in zip(ehs, global_ehs):
            geh[anx[-2]:anx[-1]+1,:,:] = eh[:]

        # verify
        getf.wait()

        for str_f in str_fs:
            original = eh_dict[str_f][slices]
            copy = getf.get_fields(str_f)
            norm = np.linalg.norm(original - copy)
            self.assertEqual(norm, 0, '%s, %g' % (self.args, norm))
    def runTest(self):
        nx, ny, nz, str_f, pt0, pt1 = self.args

        slices = common.slices_two_points(pt0, pt1)
        str_fs = common.convert_to_tuple(str_f)

        # instance
        gpu_devices = common_gpu.gpu_device_list(print_info=False)
        context = cl.Context(gpu_devices)

        mainf_list = [gpu.Fields(context, device, nx, ny, nz) \
                for device in gpu_devices]
        mainf_list.append(cpu.Fields(nx, ny, nz))
        nodef = Fields(mainf_list)
        dtype = nodef.dtype
        anx = nodef.accum_nx_list

        getf = GetFields(nodef, str_f, pt0, pt1)

        # generate random source
        global_ehs = [np.zeros(nodef.ns, dtype) for i in range(6)]
        eh_dict = dict(zip(['ex', 'ey', 'ez', 'hx', 'hy', 'hz'], global_ehs))

        for i, f in enumerate(mainf_list[:-1]):
            nx, ny, nz = f.ns
            ehs = common_random.generate_ehs(nx, ny, nz, dtype)
            f.set_eh_bufs(*ehs)
            for eh, geh in zip(ehs, global_ehs):
                geh[anx[i]:anx[i + 1], :, :] = eh[:-1, :, :]

        f = mainf_list[-1]
        nx, ny, nz = f.ns
        ehs = common_random.generate_ehs(nx, ny, nz, dtype)
        f.set_ehs(*ehs)
        for eh, geh in zip(ehs, global_ehs):
            geh[anx[-2]:anx[-1] + 1, :, :] = eh[:]

        # verify
        getf.wait()

        for str_f in str_fs:
            original = eh_dict[str_f][slices]
            copy = getf.get_fields(str_f)
            norm = np.linalg.norm(original - copy)
            self.assertEqual(norm, 0, '%s, %g' % (self.args, norm))
Пример #7
0
    def runTest(self):
        ufunc, nx, ny, nz, coeff_use, precision_float, tmax = self.args

        gpu_devices = common_gpu.gpu_device_list(print_info=False)
        context = cl.Context(gpu_devices)
        device = gpu_devices[0]
        qtask = cpu.QueueTask()
        fields = gpu.Fields(context, device, qtask, nx, ny, nz, coeff_use, precision_float)
        gpu.Core(fields)

        fields_ref = naive.Fields(nx, ny, nz, precision_float, segment_nbytes=64)
        naive.Core(fields_ref)

        # allocations
        ns = fields.ns
        dtype = fields.dtype
        strf_list = ['ex', 'ey', 'ez', 'hx', 'hy', 'hz']

        ehs = common_random.generate_ehs(nx, ny, nz, dtype, ufunc)
        fields.set_eh_bufs(*ehs)
        fields_ref.set_ehs(*ehs)

        ces, chs = common_random.generate_cs(nx, ny, nz, dtype, coeff_use)
        if 'e' in coeff_use:
            fields.set_ce_bufs(*ces)
            fields_ref.set_ces(*ces)
        if 'h' in coeff_use:
            fields.set_ch_bufs(*chs)
            fields_ref.set_chs(*chs)

        tmpf = np.zeros(fields.ns_pitch, dtype=dtype)

        # update
        if ufunc == 'e':
            for tstep in xrange(0, tmax):
                fields.update_e()
                fields_ref.update_e()
            qtask.enqueue_barrier()

            for strf, eh in zip(strf_list, ehs)[:3]:
                cl.enqueue_copy(fields.queue, tmpf, fields.get_buf(strf))
                norm = np.linalg.norm(fields_ref.get(strf) - tmpf)
                max_diff = np.abs(fields_ref.get(strf) - tmpf).max()
                self.assertEqual(norm, 0, '%s, %s, %g, %g' % (self.args, strf, norm, max_diff) )

        elif ufunc == 'h':
            for tstep in xrange(0, tmax):
                fields.update_h()
                fields_ref.update_h()

            for strf, eh in zip(strf_list, ehs)[3:]:
                cl.enqueue_copy(fields.queue, tmpf, fields.get_buf(strf))
                norm = np.linalg.norm(fields_ref.get(strf) - tmpf)
                max_diff = np.abs(fields_ref.get(strf) - tmpf).max()
                self.assertEqual(norm, 0, '%s, %s, %g, %g' % (self.args, strf, norm, max_diff) )
Пример #8
0
    def runTest(self):
        ufunc, nx, ny, nz, coeff_use, precision_float, use_cpu_core, tmax = self.args
        qtask = cpu.QueueTask()
        fields = cpu.Fields(qtask, nx, ny, nz, coeff_use, precision_float, use_cpu_core)
        cpu.Core(fields)

        fields_ref = naive.Fields(nx, ny, nz, precision_float, segment_nbytes=16)
        naive.Core(fields_ref)

        # allocations
        ns = fields.ns
        dtype = fields.dtype

        ehs = common_random.generate_ehs(nx, ny, nz, dtype, ufunc)
        fields.set_ehs(*ehs)
        fields_ref.set_ehs(*ehs)

        ces, chs = common_random.generate_cs(nx, ny, nz, dtype, coeff_use)
        if 'e' in coeff_use:
            fields.set_ces(*ces)
            fields_ref.set_ces(*ces)
        if 'h' in coeff_use:
            fields.set_chs(*chs)
            fields_ref.set_chs(*chs)

        # verify
        strf_list = ['ex', 'ey', 'ez', 'hx', 'hy', 'hz']

        if ufunc == 'e':
            for tstep in xrange(0, tmax):
                for instance in fields.instance_list:
                    instance.update_e('pre')
                    instance.update_e('post')
                fields_ref.update_e()
            fields.enqueue_barrier()

            for strf, eh in zip(strf_list, ehs)[:3]:
                norm = np.linalg.norm(fields.get(strf) - fields_ref.get(strf))
                max_diff = np.abs(fields.get(strf) - fields_ref.get(strf)).max()
                self.assertEqual(norm, 0, '%s, %s, %g, %g' % (self.args, strf, norm, max_diff) )

        elif ufunc == 'h':
            for tstep in xrange(0, tmax):
                for instance in fields.instance_list:
                    instance.update_h('pre')
                    instance.update_h('post')
                fields_ref.update_h()
            fields.enqueue_barrier()

            for strf, eh in zip(strf_list, ehs)[3:]:
                norm = np.linalg.norm(fields.get(strf) - fields_ref.get(strf))
                max_diff = np.abs(fields.get(strf) - fields_ref.get(strf)).max()
                self.assertEqual(norm, 0, '%s, %s, %g, %g' % \
                        (self.args, strf, norm, max_diff) )
Пример #9
0
    def runTest(self):
        ufunc, nx, ny, nz, coeff_use, precision_float, tmax = self.args

        fields = gpu.Fields(0, nx, ny, nz, coeff_use, precision_float)
        gpu.Core(fields)

        fields_ref = naive.Fields(nx, ny, nz, precision_float, segment_nbytes=64)
        naive.Core(fields_ref)

        # allocations
        ns = fields.ns
        dtype = fields.dtype
        strf_list = ['ex', 'ey', 'ez', 'hx', 'hy', 'hz']

        ehs = common_random.generate_ehs(nx, ny, nz, dtype, ufunc)
        fields.set_eh_bufs(*ehs)
        fields_ref.set_ehs(*ehs)

        ces, chs = common_random.generate_cs(nx, ny, nz, dtype, coeff_use)
        if 'e' in coeff_use:
            fields.set_ce_bufs(*ces)
            fields_ref.set_ces(*ces)
        if 'h' in coeff_use:
            fields.set_ch_bufs(*chs)
            fields_ref.set_chs(*chs)

        tmpf = np.zeros(fields.ns_pitch, dtype=dtype)

        # update
        if ufunc == 'e':
            for tstep in xrange(0, tmax):
                fields.update_e()
                fields_ref.update_e()

            for strf, eh in zip(strf_list, ehs)[:3]:
                cuda.memcpy_dtoh(tmpf, fields.get_buf(strf))
                norm = np.linalg.norm(fields_ref.get(strf) - tmpf)
                max_diff = np.abs(fields_ref.get(strf) - tmpf).max()
                self.assertEqual(norm, 0, '%s, %s, %g, %g' % (self.args, strf, norm, max_diff) )

        elif ufunc == 'h':
            for tstep in xrange(0, tmax):
                fields.update_h()
                fields_ref.update_h()

            for strf, eh in zip(strf_list, ehs)[3:]:
                cuda.memcpy_dtoh(tmpf, fields.get_buf(strf))
                norm = np.linalg.norm(fields_ref.get(strf) - tmpf)
                max_diff = np.abs(fields_ref.get(strf) - tmpf).max()
                self.assertEqual(norm, 0, '%s, %s, %g, %g' % (self.args, strf, norm, max_diff) )

        fields.context.pop()
Пример #10
0
    def runTest(self):
        nx, ny, nz, str_f, pt0, pt1 = self.args

        slice_xyz = common.slices_two_points(pt0, pt1)
        str_fs = common.convert_to_tuple(str_f)

        # instance
        fields = Fields(nx, ny, nz, '', 'single')
        getf = GetFields(fields, str_f, pt0, pt1) 
        
        # host allocations
        ehs = common_random.generate_ehs(nx, ny, nz, fields.dtype)
        eh_dict = dict( zip(['ex', 'ey', 'ez', 'hx', 'hy', 'hz'], ehs) )
        fields.set_ehs(*ehs)

        # verify
        getf.get_event().wait()

        for str_f in str_fs:
            original = eh_dict[str_f][slice_xyz]
            copy = getf.get_fields(str_f)
            norm = np.linalg.norm(original - copy)
            self.assertEqual(norm, 0, '%s, %g' % (self.args, norm))
Пример #11
0
    def runTest(self):
        nx, ny, nz, str_f, pt0, pt1 = self.args

        slice_xyz = common.slices_two_points(pt0, pt1)
        str_fs = common.convert_to_tuple(str_f)

        # instance
        fields = Fields(nx, ny, nz, '', 'single')
        getf = GetFields(fields, str_f, pt0, pt1)

        # host allocations
        ehs = common_random.generate_ehs(nx, ny, nz, fields.dtype)
        eh_dict = dict(zip(['ex', 'ey', 'ez', 'hx', 'hy', 'hz'], ehs))
        fields.set_ehs(*ehs)

        # verify
        getf.get_event().wait()

        for str_f in str_fs:
            original = eh_dict[str_f][slice_xyz]
            copy = getf.get_fields(str_f)
            norm = np.linalg.norm(original - copy)
            self.assertEqual(norm, 0, '%s, %g' % (self.args, norm))
Пример #12
0
    def runTest(self):
        nx, ny, nz = self.args

        # instances
        buffer_dict = {}
        buffer_dict['x+'] = cpu.BufferFields('x+', ny, nz, '', 'single')
        buffer_dict['x-'] = cpu.BufferFields('x-', ny, nz, '', 'single')

        import pyopencl as cl
        from kemp.fdtd3d.util import common_gpu
        from kemp.fdtd3d import gpu
        gpu_devices = common_gpu.gpu_device_list(print_info=False)
        context = cl.Context(gpu_devices)
        mainf_list = [ gpu.Fields(context, gpu_devices[0], nx, ny, nz) ]
        #mainf_list = [ cpu.Fields(nx, ny, nz) ]
        nodef = node.Fields(mainf_list, buffer_dict)

        # generate random source
        dtype = nodef.dtype
        ehs = common_random.generate_ehs(nx, ny, nz, dtype)
        buf_ehs_p = common_random.generate_ehs(3, ny, nz, dtype)
        buf_ehs_m = common_random.generate_ehs(3, ny, nz, dtype)
        nodef.mainf_list[0].set_eh_bufs(*ehs)
        #nodef.mainf_list[0].set_ehs(*ehs)
        nodef.buffer_dict['x+'].set_ehs(*buf_ehs_p)
        nodef.buffer_dict['x-'].set_ehs(*buf_ehs_m)
        node.Core(nodef)

        # allocations for verify
        getf_dict = {'x+': {}, 'x-': {}}
        getf_buf_dict = {'x+': {}, 'x-': {}}

        getf_dict['x+']['e'] = gpu.GetFields(nodef.mainf_list[0], ['ey', 'ez'], (nx-1, 0, 0), (nx-1, ny-1, nz-1))
        getf_dict['x+']['h'] = gpu.GetFields(nodef.mainf_list[0], ['hy', 'hz'], (nx-2, 0, 0), (nx-2, ny-1, nz-1))

        getf_buf_dict['x+']['e'] = cpu.GetFields(nodef.buffer_dict['x+'], ['ey', 'ez'], (1, 0, 0), (1, ny-1, nz-1))
        getf_buf_dict['x+']['h'] = cpu.GetFields(nodef.buffer_dict['x+'], ['hy', 'hz'], (0, 0, 0), (0, ny-1, nz-1))

        getf_dict['x-']['e'] = gpu.GetFields(nodef.mainf_list[0], ['ey', 'ez'], (1, 0, 0), (1, ny-1, nz-1))
        getf_dict['x-']['h'] = gpu.GetFields(nodef.mainf_list[0], ['hy', 'hz'], (0, 0, 0), (0, ny-1, nz-1))

        getf_buf_dict['x-']['e'] = cpu.GetFields(nodef.buffer_dict['x-'], ['ey', 'ez'], (2, 0, 0), (2, ny-1, nz-1))
        getf_buf_dict['x-']['h'] = cpu.GetFields(nodef.buffer_dict['x-'], ['hy', 'hz'], (1, 0, 0), (1, ny-1, nz-1))

        # verify
        nodef.update_e()
        nodef.update_h()
        print 'nodef, instance_list', nodef.instance_list
        print 'mainf_list[0], instance_list', nodef.mainf_list[0].instance_list

        for direction in ['x+', 'x-']:
            for e_or_h in ['e', 'h']:
                getf = getf_dict[direction][e_or_h]
                getf_buf = getf_buf_dict[direction][e_or_h]

                getf.get_event().wait()
                getf_buf.get_event().wait()

                original = getf.get_fields()
                copy = getf_buf.get_fields()
                norm = np.linalg.norm(original - copy)
                self.assertEqual(norm, 0, '%s, %g, %s, %s' % (self.args, norm, direction, e_or_h))
Пример #13
0
    def runTest(self):
        nx, ny, nz = self.args
        tmax = 10

        # instances
        buffer_dict = {}
        if rank == 0: buffer_dict['x+'] = cpu.BufferFields('x+', ny, nz, '', 'single')
        elif rank == 1: buffer_dict['x-'] = cpu.BufferFields('x-', ny, nz, '', 'single')

        import pyopencl as cl
        from kemp.fdtd3d.util import common_gpu
        from kemp.fdtd3d import gpu
        gpu_devices = common_gpu.gpu_device_list(print_info=False)
        context = cl.Context(gpu_devices)
        mainf_list = [ gpu.Fields(context, gpu_devices[0], nx, ny, nz) ]
        #mainf_list = [ cpu.Fields(nx, ny, nz, use_cpu_core=1) ]
        nodef = node.Fields(mainf_list, buffer_dict)

        # generate random source
        dtype = nodef.dtype
        ehs = common_random.generate_ehs(nx, ny, nz, dtype)
        buf_ehs = common_random.generate_ehs(3, ny, nz, dtype)
        #nodef.cpuf.set_ehs(*ehs)
        nodef.mainf_list[0].set_eh_bufs(*ehs)
        other = {0: 1, 1: 0}[rank]
        if rank == 0: 
            #nodef.buffer_dict['x+'].set_ehs(*buf_ehs)
            ExchangeMpi(nodef.buffer_dict['x+'], other, tmax)
        elif rank == 1:
            #nodef.buffer_dict['x-'].set_ehs(*buf_ehs)
            ExchangeMpi(nodef.buffer_dict['x-'], other, tmax)
        node.Core(nodef)

        # allocations for verify
        if rank == 0:
            getf_e = cpu.GetFields(nodef.buffer_dict['x+'], ['ey', 'ez'], (2, 0, 0), (2, ny-1, nz-1))
            getf_h = cpu.GetFields(nodef.buffer_dict['x+'], ['hy', 'hz'], (1, 0, 0), (1, ny-1, nz-1))
        elif rank == 1:
            getf_e = cpu.GetFields(nodef.buffer_dict['x-'], ['ey', 'ez'], (1, 0, 0), (1, ny-1, nz-1))
            getf_h = cpu.GetFields(nodef.buffer_dict['x-'], ['hy', 'hz'], (0, 0, 0), (0, ny-1, nz-1))

        # verify
        print 'nodef, instance_list', rank, nodef.instance_list
        print 'f0, instance_list', rank, nodef.mainf_list[0].instance_list
        exch = nodef.instance_list[0]
        main_core = nodef.mainf_list[0].instance_list[0]
        if rank == 0: 
            #nodef.buffer_dict['x+'].instance_list.pop(0)
            print 'bufferf x+, instance_list', rank, nodef.buffer_dict['x+'].instance_list
            core, mpi = nodef.buffer_dict['x+'].instance_list
        elif rank == 1: 
            #nodef.buffer_dict['x-'].instance_list.pop(0)
            print 'bufferf x-, instance_list', rank, nodef.buffer_dict['x-'].instance_list
            core, mpi = nodef.buffer_dict['x-'].instance_list



        for tstep in xrange(1, tmax+1):
            #if rank == 0: print 'tstep', tstep

            #nodef.update_e()
            main_core.update_e()
            if rank == 0: 
                #print tstep, rank, 'core upE'
                core.update_e('')
                #print tstep, rank, 'mpi upE'
                mpi.update_e('')
            elif rank == 1: 
                #print tstep, rank, 'core upE pre'
                core.update_e('pre')
                #print tstep, rank, 'mpi upE pre'
                mpi.update_e('pre')
                #print tstep, rank, 'core upE post'
                core.update_e('post')
                #print tstep, rank, 'mpi upE post'
                mpi.update_e('post')
            exch.update_e()

            # verify the buffer
            #print tstep, rank, 'pre get'
            getf_h.get_event().wait()
            #print tstep, rank, 'after get'
            if rank == 1:
                #print tstep, rank, 'pre save'
                np.save('rank1_h_%d' % tstep, getf_h.get_fields())
                #print tstep, rank, 'after save'
            elif rank == 0:
                no_exist_npy = True
                while no_exist_npy:
                    try:
                        arr1 = np.load('rank1_h_%d.npy' % tstep)
                        no_exist_npy = False
                    except:
                        sleep(0.5)

                arr0 = getf_h.get_fields()
                #print tstep, 'h arr0\n', arr0
                #print tstep, 'h arr1\n', arr1
                norm = np.linalg.norm(arr0 - arr1)
                if norm != 0: print tstep, 'h norm', norm
                #if tstep > 1: self.assertEqual(norm, 0, '%s, %g, h' % (self.args, norm))


            #nodef.update_h()
            main_core.update_h()
            if rank == 0: 
                #print tstep, rank, 'core upH pre'
                core.update_h('pre')
                #print tstep, rank, 'mpi upH pre'
                mpi.update_h('pre')
                #print tstep, rank, 'core upH post'
                core.update_h('post')
                #print tstep, rank, 'mpi upH post'
                mpi.update_h('post')
            elif rank == 1: 
                #print tstep, rank, 'core upH'
                core.update_h('')
                #print tstep, rank, 'mpi upH'
                mpi.update_h('')
            exch.update_h()

            getf_e.get_event().wait()
            if rank == 1:
                np.save('rank1_e_%d' % tstep, getf_e.get_fields())
            elif rank == 0:
                no_exist_npy = True
                while no_exist_npy:
                    try:
                        arr1 = np.load('rank1_e_%d.npy' % tstep)
                        no_exist_npy = False
                    except:
                        sleep(0.5)

                arr0 = getf_e.get_fields()
                norm = np.linalg.norm(arr0 - arr1)
                if norm != 0: print tstep, 'e norm', norm
                #self.assertEqual(norm, 0, '%s, %g, e' % (self.args, norm))

        '''