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) ''' print datetime.now() - t1
colorbar() """ if myrank == 1: # measure kernel execution time # from datetime import datetime # t1 = datetime.now() 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)
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()
chz_cpu = set_c(f, (0, 0, None)).copy() ''' # 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
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()
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()