コード例 #1
0
ファイル: fdtd3d.py プロジェクト: wbkifun/fdtd_accelerate
	def check_grid_size(s):
		nbytes = s.nx_total * s.ny * s.nz * np.nbytes['float32'] * 9
		if s.print_verbose:
			print('Total (%d, %d, %d) ' % (s.nx_total, s.ny, s.nz)),
			print('%1.2f %s' % utils.get_nbytes_unit(nbytes))
		for i, nx in enumerate(s.nxs):
			nbytes = nx * s.ny * s.nz * np.nbytes['float32'] * 9
			if i < s.ngpu:
				mem_size = s.gpu_devices[i].get_info(cl.device_info.GLOBAL_MEM_SIZE)
				head_str = 'GPU #%d' % i
			else:
				for line in open('/proc/meminfo'):
					if 'MemTotal' in line:
						mem_size = int(line[line.find(':')+1:line.rfind('kB')]) * 1024
						break
				head_str = 'CPU'
			if s.print_verbose:
				print('%s (%d, %d, %d) ' % (head_str, nx, s.ny, s.nz)),
				print('%1.2f %s' % utils.get_nbytes_unit(nbytes))

			if nbytes >= mem_size:
				print('Error: The required memory size %d is over the global memory %d.' %(nbytes, gmem_size))
				sys.exit()
		if s.print_verbose: print('')

		if s.nz % 32 != 0:
			print('Error: nz is not multiple of 32')
			sys.exit()
コード例 #2
0
ファイル: fdtd3d.py プロジェクト: xj361685640/fdtd_accelerate
    def check_grid_size(s):
        nbytes = s.nx_total * s.ny * s.nz * np.nbytes['float32'] * 9
        if s.print_verbose:
            print('Total (%d, %d, %d) ' % (s.nx_total, s.ny, s.nz)),
            print('%1.2f %s' % utils.get_nbytes_unit(nbytes))
        for i, nx in enumerate(s.nxs):
            nbytes = nx * s.ny * s.nz * np.nbytes['float32'] * 9
            if i < s.ngpu:
                mem_size = s.gpu_devices[i].get_info(
                    cl.device_info.GLOBAL_MEM_SIZE)
                head_str = 'GPU #%d' % i
            else:
                for line in open('/proc/meminfo'):
                    if 'MemTotal' in line:
                        mem_size = int(
                            line[line.find(':') + 1:line.rfind('kB')]) * 1024
                        break
                head_str = 'CPU'
            if s.print_verbose:
                print('%s (%d, %d, %d) ' % (head_str, nx, s.ny, s.nz)),
                print('%1.2f %s' % utils.get_nbytes_unit(nbytes))

            if nbytes >= mem_size:
                print(
                    'Error: The required memory size %d is over the global memory %d.'
                    % (nbytes, gmem_size))
                sys.exit()
        if s.print_verbose: print('')

        if s.nz % 32 != 0:
            print('Error: nz is not multiple of 32')
            sys.exit()
コード例 #3
0
for key, val in bl.items():
	print('%s\t%g\t%g' % (key, val[0], val[1]))


# Estimate the elapsed time for FDTD
import numpy as np
from utils import get_nbytes_unit

bpc = {'update_e':64.25, 'update_h':52.25}	# bytes / cell
et = lambda (bw, lt), nbytes: nbytes / bw + lt	# elapsed time

nx, ny, nz = (480, 480, 480)
print('')
print('(%d, %d, %d)' % (nx, ny, nz)),
print(' %1.2f %s' % get_nbytes_unit(nx*ny*nz*9*4))
print('%s\t%g' % ('update_e', et(bl['dtod'], bpc['update_e'] * nx*ny*nz)))
print('%s\t%g' % ('update_h', et(bl['dtod'], bpc['update_h'] * nx*ny*nz)))
print('%s\t%g' % ('dtoh,paged', et(bl['dtoh,pageable'], np.nbytes['float32'] * 2*ny*nz)))
print('%s\t%g' % ('htod,paged', et(bl['htod,pageable'], np.nbytes['float32'] * 2*ny*nz)))
print('%s\t\t%g' % ('nton', et(bl['nton'], np.nbytes['float32'] * 2*ny*nz)))

nx, ny, nz = (256, 256, 256)
print('')
print('(%d, %d, %d)' % (nx, ny, nz)),
print(' %1.2f %s' % get_nbytes_unit(nx*ny*nz*9*4))
print('%s\t%g' % ('update_e', et(bl['dtod'], bpc['update_e'] * nx*ny*nz)))
print('%s\t%g' % ('update_h', et(bl['dtod'], bpc['update_h'] * nx*ny*nz)))
print('%s\t%g' % ('dtoh,paged', et(bl['dtoh,pageable'], np.nbytes['float32'] * 2*ny*nz)))
print('%s\t%g' % ('htod,paged', et(bl['htod,pageable'], np.nbytes['float32'] * 2*ny*nz)))
print('%s\t\t%g' % ('nton', et(bl['nton'], np.nbytes['float32'] * 2*ny*nz)))
コード例 #4
0
    bl[vals[0]] = float(vals[1]), float(vals[2])

for key, val in bl.items():
    print('%s\t%g\t%g' % (key, val[0], val[1]))

# Estimate the elapsed time for FDTD
import numpy as np
from utils import get_nbytes_unit

bpc = {'update_e': 64.25, 'update_h': 52.25}  # bytes / cell
et = lambda (bw, lt), nbytes: nbytes / bw + lt  # elapsed time

nx, ny, nz = (480, 480, 480)
print('')
print('(%d, %d, %d)' % (nx, ny, nz)),
print(' %1.2f %s' % get_nbytes_unit(nx * ny * nz * 9 * 4))
print('%s\t%g' % ('update_e', et(bl['dtod'], bpc['update_e'] * nx * ny * nz)))
print('%s\t%g' % ('update_h', et(bl['dtod'], bpc['update_h'] * nx * ny * nz)))
print('%s\t%g' % ('dtoh,paged',
                  et(bl['dtoh,pageable'], np.nbytes['float32'] * 2 * ny * nz)))
print('%s\t%g' % ('htod,paged',
                  et(bl['htod,pageable'], np.nbytes['float32'] * 2 * ny * nz)))
print('%s\t\t%g' %
      ('nton', et(bl['nton'], np.nbytes['float32'] * 2 * ny * nz)))

nx, ny, nz = (256, 256, 256)
print('')
print('(%d, %d, %d)' % (nx, ny, nz)),
print(' %1.2f %s' % get_nbytes_unit(nx * ny * nz * 9 * 4))
print('%s\t%g' % ('update_e', et(bl['dtod'], bpc['update_e'] * nx * ny * nz)))
print('%s\t%g' % ('update_h', et(bl['dtod'], bpc['update_h'] * nx * ny * nz)))