-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathIOBenchmarkContiguous.f90
297 lines (247 loc) · 8.11 KB
/
IOBenchmarkContiguous.f90
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
! ____ _ __ ____ __ ____
! / __/___(_) / ___ ____/ __ \__ _____ ___ / /_ / _/__ ____
! _\ \/ __/ / _ \/ -_) __/ /_/ / // / -_|_-</ __/ _/ // _ \/ __/
! /___/\__/_/_.__/\__/_/ \___\_\_,_/\__/___/\__/ /___/_//_/\__(_)
!
!
! Copyright 2010 SciberQuest Inc.
!
! No permission is granted to reproduce this software.
!
! This is experimental software and is provided ‘‘as is’’, with no
! warranties of any kind whatsoever, no support, no promise of updates,
! or printed documentation.
!==============================================================================
! H3D IO contiguous data benchmark
!******************************************************************************
program main
use IOBenchmarkCommandLineModule
use RunConfigModule
use CartesianDecompModule
use MPIFileModule
use LogFileModule
use BoxArrayModule
use mpi
implicit none
type(RunConfig),pointer :: config => null() !
type(String),pointer :: logStream => null() !
type(MPIFile),pointer :: partFile => null() ! file for data output
type(LogFile),pointer :: runLog => null() ! log file for timings
integer masterRank
real*8, pointer, dimension(:) :: X => null() ! local particle data
! real*8, pointer, dimension(:) :: Y => null()
! real*8, pointer, dimension(:) :: Z => null()
! real*8, pointer, dimension(:) :: Vx => null()
! real*8, pointer, dimension(:) :: Vy => null()
! real*8, pointer, dimension(:) :: Vz => null()
integer*8 np
! integer*8 GetNumberOfLocalParticles
integer worldRank,worldSize
character(len=512 ) workingDir ! path to place run results in (passed on command tail)
character(len=512 ) configFileName ! file containing runtime configuration (passed on command tail)
character(len=1024) logFileName ! file where timing result are written
integer iErr
! start up
call MPI_Init(iErr)
call MPI_Comm_rank(MPI_COMM_WORLD, worldRank, iErr)
call MPI_Comm_size(MPI_COMM_WORLD, worldSize, iErr)
masterRank=0
call ProcessCommandLine( &
worldRank, &
configFileName, &
logFilename, &
workingDir, &
iErr)
if (iErr.ne.0) stop
! load run configuration from file
config => NewRunConfig()
call RunConfigLoad(config,configFileName,iErr)
if (iErr.ne.0) stop
! get the number of bytes assigned to this process.
np=RunConfigGetPerProcessDataSize(config)
np=np/8;
! ! compute the number of particles owned by this process.
! np=GetNumberOfLocalParticles( &
! worldRank, &
! worldSize, &
! RunConfigGetNX(config))
! create the log file, and log run header and parameters
runLog => NewLogFile()
call LogFileOpen( &
runLog, &
logFileName, &
MPI_COMM_WORLD, &
iErr)
if (iErr.ne.0) stop
logStream => NewString()
call RunConfigStream(config,logStream)
call StringAppend(logStream,StringNameValue("NPartLocal",np))
call LogFileWriteHeader(runLog,"H3D-IO-Benchmark-Contiguous",iErr)
call LogFileWrite(runLog,logStream,iErr)
call LogFileMarkEventStart(runLog,iErr)
call DeleteString(logStream)
! open the gda file
partFile => NewMPIFileContiguous( &
MPI_COMM_WORLD, &
masterRank, &
trim(workingDir)//"/part_1.h3dp", &
ior(MPI_MODE_WRONLY,MPI_MODE_CREATE), &
RunConfigGetCommSplitOp(config), &
RunConfigGetNComms(config), &
RunConfigGetFileSplitOp(config), &
RunConfigGetGateOp(config), &
RunConfigGetOpenGateSize(config), &
RunConfigGetWriteGateSize(config), &
RunConfigGetCloseGateSize(config), &
RunConfigGetAPI(config), &
RunConfigGetFileHints(config), &
runLog, &
iErr)
if (iErr.ne.0) stop
if (worldRank.ne.masterRank) then
! allocate and initialize the local array
allocate(X(np))
! allocate(Y(np))
! allocate(Z(np))
! allocate(Vx(np))
! allocate(Vy(np))
! allocate(Vz(np))
select case (RunConfigGetCommSplitOp(config))
case (0,1)
! 0 -comm self
! 1 - comm world
! color by proc id
call GenerateParticleData( &
real(worldRank,8), &
np, &
X)!, &
!Y, &
!Z, &
!Vx, &
!Vy, &
!Vz)
case (2,3)
! 2 - slab split
! 3 - stripe
! color by comm id
call GenerateParticleData( &
real(MPIFileGetCommId(partFile),8), &
np, &
X)!, &
!Y, &
!Z, &
!Vx, &
!Vy, &
!Vz)
end select
end if
! write the file
call MPIFileSeekF(partFile,np,MPI_REAL8,iErr)
if (iErr.ne.0) stop
call MPIFileWrite(partFile,X,iErr)
if (iErr.ne.0) stop
! call MPIFileSeekF(partFile,np,MPI_REAL8,iErr)
! if (iErr.ne.0) stop
! call MPIFileWrite(partFile,Y,iErr)
! if (iErr.ne.0) stop
!
! call MPIFileSeekF(partFile,np,MPI_REAL8,iErr)
! if (iErr.ne.0) stop
! call MPIFileWrite(partFile,Z,iErr)
! if (iErr.ne.0) stop
!
! call MPIFileSeekF(partFile,np,MPI_REAL8,iErr)
! if (iErr.ne.0) stop
! call MPIFileWrite(partFile,Vx,iErr)
! if (iErr.ne.0) stop
!
! call MPIFileSeekF(partFile,np,MPI_REAL8,iErr)
! if (iErr.ne.0) stop
! call MPIFileWrite(partFile,Vy,iErr)
! if (iErr.ne.0) stop
!
! call MPIFileSeekF(partFile,np,MPI_REAL8,iErr)
! if (iErr.ne.0) stop
! call MPIFileWrite(partFile,Vz,iErr)
! if (iErr.ne.0) stop
! clean up
! call MPIFilePrintSelf(partFile,0,iErr)
call MPIFileClose(partFile,iErr)
call DeleteMPIFile(partFile)
if (worldRank.ne.masterRank) then
deallocate(X)
! deallocate(Y)
! deallocate(Z)
! deallocate(Vx)
! deallocate(Vy)
! deallocate(Vz)
end if
call DeleteRunConfig(config)
! log elapsed time
call LogFileMarkEventEnd(runLog,iErr)
call LogFileWriteEvent(runLog,"Total_run_time",iErr)
call LogFileClose(runLog,iErr)
call DeleteLogFile(runLog)
call MPI_Finalize(iErr)
return
end program
!----------------------------------------------------------------------------
function GetNumberOfLocalParticles(worldRank,worldSize,n) result(nLocal)
implicit none
integer n(3)
integer*8 npX(3)
integer*8 nLocal,nLarge,nTotal
integer worldRank,worldSize
npX(1)=n(1)
npX(2)=n(2)
npX(3)=n(3)
nTotal=npX(1)*npX(2)*npX(3)
nLocal=nTotal/worldSize
nLarge=mod(nTotal,worldSize)
if (worldRank.lt.nLarge) then
nLocal=nLocal+1
end if
if (nLocal.lt.1) then
write(0,*)"Error: No particles on ",worldRank
stop
endif
end function
!------------------------------------------------------------------------------
subroutine init_random_seed()
INTEGER :: i, n, clock
INTEGER, DIMENSION(:), ALLOCATABLE :: seed
CALL RANDOM_SEED(size = n)
ALLOCATE(seed(n))
CALL SYSTEM_CLOCK(COUNT=clock)
seed = clock + 37 * (/ (i - 1, i = 1, n) /)
CALL RANDOM_SEED(PUT = seed)
DEALLOCATE(seed)
end subroutine
!------------------------------------------------------------------------------
subroutine GenerateParticleData(c,n,X)!,Y,Z,Vx,Vy,Vz)
implicit none
integer*8 n
real*8 c
real*8 X(n)!,Y(n),Z(n)
! real*8 Vx(n),Vy(n),Vz(n)
integer i
call init_random_seed()
call random_number(X)
! call random_number(Y)
! call random_number(Z)
! call random_number(Vx)
! call random_number(Vy)
! call random_number(Vz)
do i=1,n
! center a unit ball on x=c
X(i)=X(i)-0.5+c
! center others on origin
! Y(i)=Y(i)-0.5
! Z(i)=Z(i)-0.5
! Vx(i)=Vx(i)-0.5
! Vy(i)=Vy(i)-0.5
! Vz(i)=Vz(i)-0.5
! write(0,*)i,',',X(i),',',Y(i),',',Z(i),',',Vx(i),',',Vy(i),',',Vz(i)
enddo
return
end subroutine