示例#1
0
    ion()
    imsh = imshow(np.ones((ny, nz), 'f'),
                  cmap=cm.hot,
                  origin='lower',
                  vmin=0,
                  vmax=0.01)
    colorbar()

    # measure execution time
    from datetime import datetime
    t1 = datetime.now()

    # main loop
    for tn in xrange(1, 100 + 1):
        for sn in xrange(4):
            dielectric.update_h(nx, ny, nz, cl[sn], ex, ey, ez, hx, hy, hz,
                                chx, chy, chz)

            dielectric.update_e(nx, ny, nz, dl[sn], ex, ey, ez, hx, hy, hz,
                                cex, cey, cez)

            ex[:, ny / 2, nz / 2] += np.sin(0.1 * (tn + sn / 5.))

        dielectric.update_h(nx, ny, nz, cl[sn], ex, ey, ez, hx, hy, hz, chx,
                            chy, chz)
        '''
		if tn%10 == 0:
		#if tn == 100:
			print 'tn =', tn
			imsh.set_array( ex[nx/2,:,:]**2 )
			draw()
			#savefig('./png-wave/%.5d.png' % tn) 
示例#2
0
        start = cuda.Event()
        stop = cuda.Event()
        start.record()

        # main loop
    for tn in xrange(1, 11):
        if myrank == 0:
            dielectric.update_e(
                8, nx, ny, nz, ex_cpu, ey_cpu, ez_cpu, hx_cpu, hy_cpu, hz_cpu, cex_cpu, cey_cpu, cez_cpu
            )

            ex_cpu[:, :, nz - 1] = mpi.world.recv(myrank + 1, 0)
            ey_cpu[:, :, nz - 1] = mpi.world.recv(myrank + 1, 1)

            dielectric.update_h(
                8, nx, ny, nz, ex_cpu, ey_cpu, ez_cpu, hx_cpu, hy_cpu, hz_cpu, chx_cpu, chy_cpu, chz_cpu
            )

            mpi.world.send(myrank + 1, 0, hx_cpu[:, :, nz - 1])
            mpi.world.send(myrank + 1, 1, hy_cpu[:, :, nz - 1])

        else:
            for i, Dg in enumerate(Dg_list):
                update_e.prepared_call(Dg, nnx, nny, nnz, idx0_list[i], ex_gpu, ey_gpu, ez_gpu, hx_gpu, hy_gpu, hz_gpu)

            if myrank == 2:
                update_src.prepared_call((1, 1), nnx, nny, nnz, np.int32(tn), ex_gpu)

            mpi.world.send(myrank - 1, 0, cuda.from_device(int(ex_gpu), (nx, ny), np.float32))
            mpi.world.send(myrank - 1, 1, cuda.from_device(int(ey_gpu), (nx, ny), np.float32))
            if myrank != 3:
示例#3
0
	# prepare for plot
	from matplotlib.pyplot import *
	ion()
	imsh = imshow(np.ones((ny,nz),'f'), cmap=cm.hot, origin='lower', vmin=0, vmax=0.01)
	colorbar()

	# measure execution time
	from datetime import datetime
	t1 = datetime.now()

	# main loop
	for tn in xrange(1, 100+1):
		for sn in xrange(4):
			dielectric.update_h(
					nx, ny, nz, cl[sn],
					ex, ey, ez, hx, hy, hz, 
					chx, chy, chz)

			dielectric.update_e(
					nx, ny, nz, dl[sn],
					ex, ey, ez, hx, hy, hz, 
					cex, cey, cez)

			ex[:,ny/2,nz/2] += np.sin(0.1*(tn+sn/5.))

		dielectric.update_h(
				nx, ny, nz, cl[sn],
				ex, ey, ez, hx, hy, hz, 
				chx, chy, chz)

		'''
示例#4
0
	# prepare for plot
	from matplotlib.pyplot import *
	ion()
	imsh = imshow(np.ones((ny,nz),'f'), cmap=cm.hot, origin='lower', vmin=0, vmax=0.001)
	colorbar()
	'''

    # measure kernel execution time
    from datetime import datetime
    t1 = datetime.now()

    # main loop
    for tn in xrange(1, 1001):
        dielectric.update_e(8, nx, ny, nz, ex_cpu, ey_cpu, ez_cpu, hx_cpu,
                            hy_cpu, hz_cpu, cex_cpu, cey_cpu, cez_cpu)

        ex_cpu[:, ny / 2, nz / 2] += np.sin(0.1 * tn)

        dielectric.update_h(8, nx, ny, nz, ex_cpu, ey_cpu, ez_cpu, hx_cpu,
                            hy_cpu, hz_cpu, chx_cpu, chy_cpu, chz_cpu)
        '''
		if tn%10 == 0:
		#if tn == 100:
			print 'tn =', tn
			imsh.set_array( ex_cpu[nx/2,:,:]**2 )
			draw()
			#savefig('./png-wave/%.5d.png' % tstep) 
		'''

    print datetime.now() - t1
# prepare for plot
from matplotlib.pyplot import *
ion()
imsh = imshow(np.ones((nx,ny),'f').T, cmap=cm.hot, origin='lower', vmin=0, vmax=0.005)
colorbar()
'''

# measure kernel execution time
from datetime import datetime
flop = (nx*ny*nz*30)*tgap
flops = np.zeros(tmax/tgap+1)
t1 = datetime.now()

# main loop
for tn in xrange(1, tmax+1):
	dielectric.update_h(*eh_fields)
	dielectric.update_e(*(eh_fields+ce_fields))
	ez[nx/2,ny/2,:] += np.sin(0.1*tn)

	if tn%tgap == 0:
		dt = datetime.now()-t1
		flops[tn/tgap] = flop/(dt.seconds + dt.microseconds*1e-6)*1e-9
		print "[%s] %d/%d (%d %%) %1.3f GFLOPS\r" % (dt, tn, tmax, float(tn)/tmax*100, flops[tn/tgap]),
		sys.stdout.flush()
		#imsh.set_array( ez[:,:,nz/2].T**2 )
		#draw()
		#savefig('./png-wave/%.5d.png' % tn) 
		t1 = datetime.now()

print "\navg: %1.2f GFLOPS" % flops[2:-2].mean()
示例#6
0
from matplotlib.pyplot import *
ion()
imsh = imshow(np.ones((nx,ny),'f').T, cmap=cm.hot, origin='lower', vmin=0, vmax=0.005)
colorbar()
'''

# measure kernel execution time
from datetime import datetime

flop = (nx * ny * nz * 30) * tgap
flops = np.zeros(tmax / tgap + 1)
t1 = datetime.now()

# main loop
for tn in xrange(1, tmax + 1):
    dielectric.update_h(*eh_fields)
    dielectric.update_e(*(eh_fields + ce_fields))
    ez[nx / 2, ny / 2, :] += np.sin(0.1 * tn)

    if tn % tgap == 0:
        dt = datetime.now() - t1
        flops[tn / tgap] = flop / (dt.seconds + dt.microseconds * 1e-6) * 1e-9
        print "[%s] %d/%d (%d %%) %1.3f GFLOPS\r" % (
            dt, tn, tmax, float(tn) / tmax * 100, flops[tn / tgap]),
        sys.stdout.flush()
        #imsh.set_array( ez[:,:,nz/2].T**2 )
        #draw()
        #savefig('./png-wave/%.5d.png' % tn)
        t1 = datetime.now()

print "\navg: %1.2f GFLOPS" % flops[2:-2].mean()