Révision 108
| Pi/XPU/PiXpuMPI.py (revision 108) | ||
|---|---|---|
| 247 | 247 |
|
| 248 | 248 |
r=1 |
| 249 | 249 |
time_start=time.time() |
| 250 |
for Device in Devices: |
|
| 251 |
InputCL={}
|
|
| 252 |
InputCL['Iterations']=IterationsMPI |
|
| 253 |
InputCL['Steps']=Redo |
|
| 254 |
InputCL['Blocks']=Blocks |
|
| 255 |
InputCL['Threads']=Threads |
|
| 250 |
# Distribution of Devices over nodes |
|
| 251 |
InputCL={}
|
|
| 252 |
InputCL['Iterations']=IterationsMPI |
|
| 253 |
InputCL['Steps']=Redo |
|
| 254 |
InputCL['Blocks']=Blocks |
|
| 255 |
InputCL['Threads']=Threads |
|
| 256 |
InputCL['RNG']=RNG |
|
| 257 |
InputCL['ValueType']=ValueType |
|
| 258 |
for Device in Devices[1:]: |
|
| 259 |
print "Send to device %i on rank %i" % (Device,r) |
|
| 256 | 260 |
InputCL['Device']=Device |
| 257 |
InputCL['RNG']=RNG |
|
| 258 |
InputCL['ValueType']=ValueType |
|
| 259 |
print "Send to device %i on rank %i" % (Device,r) |
|
| 260 | 261 |
comm.send('CONTINUE',dest=r,tag=11)
|
| 261 | 262 |
comm.send(InputCL,dest=r,tag=11) |
| 262 | 263 |
r+=1 |
| 263 | 264 |
|
| 264 |
Inside=0 |
|
| 265 |
NewIterations=0 |
|
| 266 |
for slave in xrange(1,len(Devices)+1): |
|
| 267 |
print "slave %i" % slave |
|
| 265 |
# Compute on rank 0 |
|
| 266 |
print "Compute on rank 0" |
|
| 267 |
InputCL['Device']=Devices[0] |
|
| 268 |
OutputCL=MetropolisOpenCL(InputCL) |
|
| 269 |
Inside=OutputCL['Inside'] |
|
| 270 |
NewIterations=OutputCL['NewIterations'] |
|
| 271 |
|
|
| 272 |
for slave in xrange(1,len(Devices)): |
|
| 273 |
print "Get OutputCL from %i" % slave |
|
| 268 | 274 |
OutputCL=comm.recv(source=slave,tag=11) |
| 269 |
print "OutputCL from rank %s %s" % (slave,OutputCL)
|
|
| 275 |
print OutputCL
|
|
| 270 | 276 |
NewIterations+=OutputCL['NewIterations'] |
| 271 | 277 |
Inside+=OutputCL['Inside'] |
| 272 | 278 |
|
| 273 | 279 |
Duration=time.time()-time_start |
| 274 | 280 |
print "Pi estimation %.8f" % (4./NewIterations*Inside) |
| 275 | 281 |
except: |
| 276 |
print "Problem with (%i,%i) // computations on OpenCL" % (Blocks,Threads)
|
|
| 277 |
Duration=OutputCL['Duration'] |
|
| 278 |
NewIterations=OutputCL['NewIterations'] |
|
| 282 |
print "Problem with (%i,%i) // computations on OpenCL" % (Blocks,Threads) |
|
| 283 |
#Duration=OutputCL['Duration']
|
|
| 284 |
#NewIterations=OutputCL['NewIterations']
|
|
| 279 | 285 |
Rate=NewIterations/Duration |
| 280 | 286 |
|
| 281 | 287 |
avgD=numpy.append(avgD,numpy.average(Duration)) |
| ... | ... | |
| 307 | 313 |
if Signal=='CONTINUE': |
| 308 | 314 |
# Receive information from Master |
| 309 | 315 |
InputCL=comm.recv(source=0,tag=11) |
| 310 |
print "Parameters retreive from master %s " % InputCL |
|
| 316 |
print "Parameters retreive for rank %s of %s on %s from master:" % (rank,RankSize,gethostname()) |
|
| 317 |
print "Input CL:" % InputCL |
|
| 311 | 318 |
# Execute on slave |
| 312 | 319 |
OutputCL=MetropolisOpenCL(InputCL) |
| 313 |
print OutputCL |
|
| 320 |
print "Output CL:" % OutputCL
|
|
| 314 | 321 |
# Send information to Master |
| 315 | 322 |
comm.send(OutputCL,dest=0,tag=11) |
| 316 | 323 |
print "Data sent to master" |
Formats disponibles : Unified diff