예제 #1
0
파일: billar.py 프로젝트: bvillasen/billar
  print "Timing Info saved in: cuda_profile_1.log \n\n"
  sys.exit()
###########################################################################
###########################################################################


changeInitial = True
savePos = False
start = cuda.Event()
end = cuda.Event()
occupancyOld, occupancy = 0, 0
launchCounter = 0
start.record()
while occupancyOld < maxTimeIndx:
  occupancy = sum(timesOccupancy_d.get()>=nParticles)
  if occupancy>occupancyOld or occupancy==0: printProgressTime( occupancy, maxTimeIndx, start.time_till(end.record().synchronize())*1e-3 )
  occupancyOld = occupancy
  mainKernel(np.uint8(usingAnimation), np.int32(nParticles), np.int32(collisionsPerRun), np.int32(nCircles), circlesCaract_d, np.int32(nLines), linesCaract_d,
	    initialPosX_d, initialPosY_d, initialVelX_d, initialVelY_d, initialRegionX_d, initialRegionY_d,
	    outPosX_d, outPosY_d, times_d,
	    np.float32(deltaTime_anim), timesIdx_anim_d,
	    np.float32( deltaTime_radius ), timesIdx_rad_d, timesOccupancy_d, radiusAll_d,
	    np.uint8(savePos), np.int32(particlesForPlot), np.uint8(changeInitial),
	    np.intp(0),  grid=grid, block=block)
  launchCounter += 1
  #if runNumber%5==0  and plotting: plotData( runNumber )
print "\n\nFinished in : {0:.4f}  sec\n".format( float( start.time_till(end.record().synchronize())*1e-3 ) ) 

#Get the results
#Save data
dataDir = currentDirectory + "/data"
예제 #2
0
  print " Total particles: ", nParticles*nProc
  print ' Particles per gpu: ', nParticles
  print ' nSteps: ', totalSteps
  print ''
MPIcomm.Barrier()


computeTime  = 0
transferTime = 0
saveTime = 0
step = 0
start, end = cuda.Event(), cuda.Event()
startT = cuda.Event()
startT.record()
for stepCounter in range(totalSteps):
  if stepCounter%1==0 and pId==0: printProgressTime( stepCounter, totalSteps,  computeTime + transferTime + saveTime )
  if stepCounter%4==0:
    #Save positions
    start.record()
    posHD.create_dataset( '{0:03}'.format(stepCounter/4), data=posSend_h )
    end.record(), end.synchronize()
    saveTime += start.time_till(end)*1e-3
  timeStep()
  
 
if pId == 0:
  end.record(), end.synchronize()
  totalTimeReal = startT.time_till(end)*1e-3
  totalTime = computeTime + transferTime + saveTime
  h, m, s = timeSplit( totalTime )
  print '\n\nTotal time: {0}:{1:02}:{2:02} '.format( h, m, s )
예제 #3
0
파일: nBody.py 프로젝트: bvillasen/nBody
  pAnim.updateFunc = animationUpdate
  pAnim.keyboard = keyboard
  pAnim.startAnimation()
  
  





print ' nSteps: {0} \n'.format( totalSteps )
print " Output: {0} \n".format( outDataFile )
start, end = cuda.Event(), cuda.Event()
for stepCounter in range(totalSteps):
  start.record()
  if stepCounter%1 == 0: printProgressTime( stepCounter, totalSteps,  runningTime )
  getEnergy( stepCounter, simulationTime, energyList )
  moveParticles( cudaPre(dt), posX_d, posY_d, posZ_d, velX_d, velY_d, velZ_d, accelX_d, accelY_d, accelZ_d )
  getAcccelKernel( np.int32(nParticles), GMass, np.int32(usingAnimation),
	      posX_d, posY_d, posZ_d, posX_d, posY_d, posZ_d,
	      velX_d, velY_d, velZ_d, accelX_d, accelY_d, accelZ_d,
	      cudaPre( dt ), cudaPre(epsilon), np.int32(1),
	      np.intp(0),   grid=grid, block=block )
  simulationTime += dt
  end.record()
  end.synchronize()
  runningTime += start.time_till(end)*1e-3
  
  
  
h, m, s = timeSplit( runningTime )
예제 #4
0
  volumeRender.animate()

#Open outFile
snapsDir = dataDir + 'snapshots/'
ensureDirectory( snapsDir )
n = len( [ f for f in os.listdir( snapsDir ) if f.find(timeDirection)>0 ] )
snapsFileName = snapsDir + 'psi_{0}_{1}.h5'.format( timeDirection, n )
snapsFile = h5.File( snapsFileName, 'w')
  
print "\nnPoints: {0}x{1}x{2}".format(nWidth, nHeight, nWidth )
print 'Snapshots File: ', snapsFileName
print "Starting Real Dynamics: {0} timeUnits, dt: {1:1.2e} \n".format( endTime, dtReal )  

printCounter = 0
start, end = cuda.Event(), cuda.Event()
start.record()
for n in range( nSnapshots ):
  end.record().synchronize()
  printProgressTime( n, nSnapshots,  start.time_till(end)*1e-3 )
  saveSnapshot( n, snapsFile, simulationTime, psi_d.get() )
  [rk4_texture_iteration() for i in range(nPartialIter)]
  simulationTime += dtReal*nPartialIter
printProgressTime( nSnapshots, nSnapshots,  start.time_till(end)*1e-3 )
saveSnapshot( nSnapshots, snapsFile, simulationTime, psi_d.get() )
end.record().synchronize()


print "\n\nEnd Real Dynamics "  
print 'Time: {0:.0f}\n'.format( start.time_till(end)*1e-3 )

예제 #5
0
파일: quantum.py 프로젝트: bvillasen/phyGPU
  volumeRender.specialKeys = specialKeyboardFunc
  volumeRender.stepFunc = stepFuntion
  #run volumeRender animation
  volumeRender.animate()



print "nPoints: {0}x{1}x{2}".format(nWidth, nHeight, nWidth )
print "Starting Imaginary Dynamics: {0} timeUnits, dt: {1:1.2e} \n".format( timeRelax, dtImag )
simulationTime = -timeRelax
printCounter = 0
start, end = cuda.Event(), cuda.Event()
start.record()
while simulationTime < 0:
  if timeRelax+simulationTime >= printCounter*timeRelax/500.:
    end.record().synchronize()
    printProgressTime( timeRelax + simulationTime, timeRelax,  start.time_till(end)*1e-3 )
    printCounter += 1
  imaginaryStep()
  simulationTime += dtImag
print "\nEnd Imaginary Dynamics\n "
saveState( fileName='initial/converged/psiConverged.h5')

#applyTransition = True
#timeTransition()
##cuda.memset_d8(activity_d.ptr, 1, nBlocks3D )
#endTime = 1
#nIterations = int( endTime/dtReal )
#print "Starting Real Dynamics: {0} timeUnits ".format( endTime )
#[ rk4_iteration() for i in range(nIterations) ]