Medium Memory Model and Large Array in Fortranm = i;}printf("a[0]=%g b[0]=%g c[0]=%g\n", a[0], b[0], c[0]);printf("m=%lld a[%lld]=%g b[%lld]=%gc[%lld]=%g\n",m,m,a[m],m,b[m],m,c[m]);return 0;}% pgcc –mcmodel=medium –o bigadd bigadd.cWhen SIZE is greater than 2G/4, and the arrays are of type float with 4 bytes per element, the size of each arrayis greater than 2GB. With pgcc, using the –mcmodel=medium switch, a static data object can now be > 2GB insize. If you execute with these settings in your environment, you may see the following:% bigaddSegmentation faultExecution fails because the stack size is not large enough. You can most likely correct this error by using thelimit stacksize command to reset the stack size in your environment:% limit stacksize 3000MNoteThe command limit stacksize unlimited probably does not provide as large a stack as we are usingin the Example 13.1.% bigadda[0]=1 b[0]=2 c[0]=3n=599990000 a[599990000]=5.9999e+08 b[599990000]=1.19998e+09c[599990000]=1.79997e+09The size of the bss section of the bigadd executable is now larger than 2GB:% size –-format=sysv bigadd | grep bss.bss 4800000008 5245696% size -–format=sysv bigadd | grep TotalTotal 4800005080Medium Memory Model and Large Array in Fortran172The following example works with the PGFORTRAN, PGF95, and PGF77 compilers included in Release 2011.Both compilers use 64-bit addresses and index arithmetic when the –mcmodel=medium option is used.Consider the following example:Example 13.2. Medium Memory Model and Large Array in Fortran% cat mat.fprogram matinteger i, j, k, size, l, m, n parameter (size=16000) ! >2GBparameter (m=size,n=size)real*8 a(m,n),b(m,n),c(m,n),ddo i = 1, mdo j = 1, na(i,j)=10000.0D0*dble(i)+dble(j)b(i,j)=20000.0D0*dble(i)+dble(j)enddoenddo
Chapter 13. Programming Considerations for 64-Bit Environments!$omp parallel!$omp dodo i = 1, mdo j = 1, nc(i,j) = a(i,j) + b(i,j)enddoenddo!$omp dodo i=1,mdo j = 1, nd = 30000.0D0*dble(i)+dble(j)+dble(j)if(d .ne. c(i,j)) thenprint *,"err i=",i,"j=",jprint *,"c(i,j)=",c(i,j)print *,"d=",dstopendifenddoenddo!$omp end parallelprint *, "M =",M,", N =",Nprint *, "c(M,N) = ", c(m,n)endWhen compiled with the PGFORTRAN compiler using –mcmodel=medium:% pgfortran –mp –o mat mat.f –i8 –mcmodel=medium% setenv OMP_NUM_THREADS 2% matM = 16000 , N = 16000c(M,N) = 480032000.0000000Large Array and Small Memory Model in FortranThe following example uses large, dynamically-allocated arrays. The code is divided into a main andsubroutine so you could put the subroutine into a shared library. Dynamic allocation of large arrays savesspace in the size of executable and saves time initializing data. Further, the routines can be compiled with 32-bit compilers, by just decreasing the parameter size.Example 13.3. Large Array and Small Memory Model in Fortran% cat mat_allo.f90program mat_allointeger i, jinteger size, m, nparameter (size=16000)parameter (m=size,n=size)double precision, allocatable::a(:,:),b(:,:),c(:,:)allocate(a(m,n), b(m,n), c(m,n))do i = 100, m, 1do j = 100, n, 1a(i,j) = 10000.0D0 * dble(i) + dble(j)b(i,j) = 20000.0D0 * dble(i) + dble(j)enddoenddocall mat_add(a,b,c,m,n)print *, "M =",m,",N =",n173
- Page 2 and 3:
While every precaution has been tak
- Page 5 and 6:
PGI ® Compiler User’s Guide4. Us
- Page 7 and 8:
PGI ® Compiler User’s GuideRefer
- Page 12 and 13:
xii14.6. Intrinsic Header File Orga
- Page 14 and 15:
xiv13.3. Large Array and Small Memo
- Page 16 and 17:
Organizationxvi• Fortran 95 Handb
- Page 18 and 19:
Conventionsin this guide with which
- Page 21 and 22:
Chapter 1. Getting StartedThis chap
- Page 23 and 24:
Chapter 1. Getting StartedWhere:opt
- Page 25 and 26:
Chapter 1. Getting Startedfilename.
- Page 27 and 28:
Chapter 1. Getting Startedfilename.
- Page 29 and 30:
Chapter 1. Getting Startedparallel
- Page 31 and 32:
Chapter 1. Getting Startedas execut
- Page 33 and 34:
Chapter 1. Getting Startedar or ran
- Page 35 and 36:
Chapter 1. Getting StartedTo do thi
- Page 37 and 38:
Chapter 2. Using Command LineOption
- Page 39 and 40:
Chapter 2. Using Command Line Optio
- Page 41 and 42:
Chapter 2. Using Command Line Optio
- Page 43 and 44:
Chapter 3. Optimizing & Parallelizi
- Page 45 and 46:
Chapter 3. Optimizing & Parallelizi
- Page 47 and 48:
Chapter 3. Optimizing & Parallelizi
- Page 49 and 50:
Chapter 3. Optimizing & Parallelizi
- Page 51 and 52:
Chapter 3. Optimizing & Parallelizi
- Page 53 and 54:
Chapter 3. Optimizing & Parallelizi
- Page 55 and 56:
Chapter 3. Optimizing & Parallelizi
- Page 57 and 58:
Chapter 3. Optimizing & Parallelizi
- Page 59 and 60:
Chapter 3. Optimizing & Parallelizi
- Page 61 and 62:
Chapter 3. Optimizing & Parallelizi
- Page 63 and 64:
Chapter 3. Optimizing & Parallelizi
- Page 65 and 66:
Chapter 3. Optimizing & Parallelizi
- Page 67:
Chapter 3. Optimizing & Parallelizi
- Page 70 and 71:
Invoking Function Inlining50except:
- Page 72 and 73:
Creating an Inline Librarylevel of
- Page 74 and 75:
Restrictions on InliningA Fortran s
- Page 76 and 77:
OpenMP OverviewFortran directives a
- Page 78 and 79:
Task OverviewN = 1000DO I = 1, NV(I
- Page 80 and 81:
C/C++ Parallelization PragmasC/C++
- Page 82 and 83:
Directive and Pragma ClausesFortran
- Page 84 and 85:
Directive and Pragma ClausesThis cl
- Page 86 and 87:
Run-time Library RoutinesRun-time L
- Page 88 and 89:
Run-time Library RoutinesRun-time L
- Page 90 and 91:
Environment VariablesRun-time Libra
- Page 93 and 94:
Chapter 6. Using MPIMessage Passing
- Page 95 and 96:
Chapter 6. Using MPIyou are using M
- Page 97 and 98:
Chapter 6. Using MPIthe root of the
- Page 99 and 100:
Chapter 6. Using MPIcorrelated with
- Page 101:
Chapter 6. Using MPI• Add the fol
- Page 104 and 105:
TerminologyAvailability84The PGI 11
- Page 106 and 107:
System Requirements86Vector operati
- Page 108 and 109:
Memory Model88• waits for complet
- Page 110 and 111:
Accelerator DirectivesAccelerator D
- Page 112 and 113:
Accelerator Directives• Initial d
- Page 114 and 115:
Accelerator DirectivesThis directiv
- Page 116 and 117:
Accelerator Directive ClausesUse th
- Page 118 and 119:
Environment Variables• Interfaces
- Page 120 and 121:
PGI Unified Binary for Accelerators
- Page 122 and 123:
Profiling Accelerator KernelsWith '
- Page 124 and 125:
Supported IntrinsicsTable 7.5. Supp
- Page 126 and 127:
References related to AcceleratorsT
- Page 128 and 129:
PGI Proprietary C and C++ Pragmas10
- Page 130 and 131:
Scope of Fortran Directives and Com
- Page 132 and 133:
Scope of C/C++ Pragmas and Command-
- Page 134 and 135:
Prefetch Directives and Pragmas114d
- Page 136 and 137:
C$PRAGMA CTable 8.2. !DEC$ Directiv
- Page 138 and 139:
Using System Library Routines118voi
- Page 140 and 141:
Creating and Using Dynamic Librarie
- Page 142 and 143: Creating and Using Dynamic-Link Lib
- Page 144 and 145: Creating and Using Dynamic-Link Lib
- Page 146 and 147: Creating and Using Dynamic-Link Lib
- Page 148 and 149: Creating and Using Dynamic-Link Lib
- Page 150 and 151: Using LIB3FStep 3: Run the exe to e
- Page 152 and 153: Setting Environment VariablesIn bas
- Page 154 and 155: PGI-Related Environment VariablesEn
- Page 156 and 157: PGI Environment VariablesLD_LIBRARY
- Page 158 and 159: PGI Environment VariablesNCPUS138Se
- Page 160 and 161: PGI Environment VariablesThe value
- Page 162 and 163: Using Environment Modules on LinuxT
- Page 164 and 165: 144
- Page 166 and 167: Deploying Applications on Linux146T
- Page 168 and 169: Code Generation and Processor Archi
- Page 170 and 171: 150
- Page 172 and 173: Inter-language Calling Consideratio
- Page 174 and 175: Compatible Data TypesNoteFortran Ty
- Page 176 and 177: Array Indices! Fortran function ret
- Page 178 and 179: ExamplesCompile and execute the pro
- Page 180 and 181: Examples160int a,b,c;a=8; b=2;print
- Page 182 and 183: Win32 Calling Conventionscout
- Page 184 and 185: Win32 Calling Conventions164call wo
- Page 186 and 187: 166
- Page 188 and 189: Large Static Data in LinuxC/C++ Dat
- Page 190 and 191: Practical Limitations of Large Arra
- Page 194 and 195: Large Array and Small Memory Model
- Page 196 and 197: Extended Inline AssemblyExtended In
- Page 198 and 199: Extended Inline Assemblyexample2:..
- Page 200 and 201: Extended Inline Assembly180movq %rs
- Page 202 and 203: Extended Inline AssemblyConstraintw
- Page 204 and 205: Extended Inline AssemblyConstraintu
- Page 206 and 207: Extended Inline AssemblyConstraintM
- Page 208 and 209: Extended Inline AssemblyModifierDes
- Page 210 and 211: Intrinsicsvoid example21(){void * s
- Page 212 and 213: suboptions, 18syntax, 2, 17Commands
- Page 214 and 215: InstallLinux portability package, 1
- Page 216 and 217: modifier *, 186, 186modifier &, 186
- Page 218: optimization, 39-tp option, 39UNIXc