Skip to content

Commit 390769a

Browse files
committed
compiler: always use long for alloc sizes
1 parent afb0edf commit 390769a

3 files changed

Lines changed: 23 additions & 26 deletions

File tree

devito/passes/iet/definitions.py

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -90,17 +90,13 @@ def __init__(self, rcompile=None, sregistry=None, platform=None, **kwargs):
9090
self.rcompile = rcompile
9191
self.sregistry = sregistry
9292
self.platform = platform
93-
self.index_mode = kwargs.get('options', {'index-mode': 'int32'})['index-mode']
9493

9594
def intm(self, nbytes):
96-
if self.index_mode == 'int64':
97-
try:
98-
syms = retrieve_symbols(nbytes)
99-
return nbytes.subs({s: LONG(s) for s in syms})
100-
except AttributeError:
101-
return LONG(nbytes)
102-
else:
103-
return nbytes
95+
try:
96+
syms = retrieve_symbols(nbytes)
97+
return nbytes.subs({s: LONG(s) for s in syms})
98+
except AttributeError:
99+
return LONG(nbytes)
104100

105101
def _alloc_object_on_low_lat_mem(self, site, obj, storage):
106102
"""
@@ -562,10 +558,10 @@ def process(self, graph):
562558

563559
class DeviceAwareDataManager(DataManager):
564560

565-
def __init__(self, **kwargs):
566-
self.gpu_fit = kwargs['options']['gpu-fit']
567-
self.gpu_create = kwargs['options']['gpu-create']
568-
self.pmode = kwargs['options'].get('place-transfers')
561+
def __init__(self, options=None, **kwargs):
562+
self.gpu_fit = options['gpu-fit']
563+
self.gpu_create = options['gpu-create']
564+
self.pmode = options.get('place-transfers')
569565

570566
super().__init__(**kwargs)
571567

examples/mpi/overview.ipynb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -486,9 +486,9 @@
486486
" MPI_Request rsend;\n",
487487
"\n",
488488
" float *restrict bufg_vec __attribute__ ((aligned (64)));\n",
489-
" posix_memalign((void**)(&bufg_vec),64,x_size*y_size*sizeof(float));\n",
489+
" posix_memalign((void**)(&bufg_vec),64,sizeof(float)*(long)(y_size)*(long)(x_size));\n",
490490
" float *restrict bufs_vec __attribute__ ((aligned (64)));\n",
491-
" posix_memalign((void**)(&bufs_vec),64,x_size*y_size*sizeof(float));\n",
491+
" posix_memalign((void**)(&bufs_vec),64,sizeof(float)*(long)(y_size)*(long)(x_size));\n",
492492
"\n",
493493
" MPI_Irecv(bufs_vec,x_size*y_size,MPI_FLOAT,fromrank,13,comm,&(rrecv));\n",
494494
" if (torank != MPI_PROC_NULL)\n",

examples/performance/00_overview.ipynb

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -725,7 +725,8 @@
725725
" }\n",
726726
" }\n",
727727
" STOP(section0,timers)\n",
728-
"}\n"
728+
"}\n",
729+
"\n"
729730
]
730731
}
731732
],
@@ -1192,13 +1193,13 @@
11921193
"int Kernel(struct dataobj *restrict f_vec, struct dataobj *restrict u_vec, const float h_y, const int time_M, const int time_m, const int x0_blk0_size, const int x_M, const int x_m, const int y0_blk0_size, const int y_M, const int y_m, const int z_M, const int z_m, const int nthreads, const int z_size, const int x_size, const int y_size, struct profiler * timers)\n",
11931194
"{\n",
11941195
" float **restrict pr2_vec __attribute__ ((aligned (64)));\n",
1195-
" posix_memalign((void**)(&pr2_vec),64,nthreads*sizeof(float*));\n",
1196+
" posix_memalign((void**)(&pr2_vec),64,sizeof(float*)*(long)(nthreads));\n",
11961197
" float *restrict r0_vec __attribute__ ((aligned (64)));\n",
1197-
" posix_memalign((void**)(&r0_vec),64,x_size*y_size*z_size*sizeof(float));\n",
1198+
" posix_memalign((void**)(&r0_vec),64,sizeof(float)*(long)(z_size)*(long)(y_size)*(long)(x_size));\n",
11981199
" #pragma omp parallel num_threads(nthreads)\n",
11991200
" {\n",
12001201
" const int tid = omp_get_thread_num();\n",
1201-
" posix_memalign((void**)(&(pr2_vec[tid])),64,z_size*(y0_blk0_size + 4)*sizeof(float));\n",
1202+
" posix_memalign((void**)(&(pr2_vec[tid])),64,sizeof(float)*(long)(z_size)*(4 + (long)(y0_blk0_size)));\n",
12021203
" }\n",
12031204
"\n",
12041205
" float (*restrict f)[f_vec->size[1]][f_vec->size[2]] __attribute__ ((aligned (64))) = (float (*)[f_vec->size[1]][f_vec->size[2]]) f_vec->data;\n",
@@ -1412,7 +1413,7 @@
14121413
"name": "stdout",
14131414
"output_type": "stream",
14141415
"text": [
1415-
"posix_memalign((void**)(&r0_vec),64,x_size*y_size*z_size*sizeof(float));\n"
1416+
"posix_memalign((void**)(&r0_vec),64,sizeof(float)*(long)(z_size)*(long)(y_size)*(long)(x_size));\n"
14161417
]
14171418
}
14181419
],
@@ -1483,13 +1484,13 @@
14831484
"int Kernel(struct dataobj *restrict f_vec, struct dataobj *restrict u_vec, const float h_y, const int time_M, const int time_m, const int x_M, const int x_m, const int y_M, const int y_m, const int z_M, const int z_m, const int nthreads, const int z_size, const int x_size, const int y_size, struct profiler * timers)\n",
14841485
"{\n",
14851486
" float **restrict pr2_vec __attribute__ ((aligned (64)));\n",
1486-
" posix_memalign((void**)(&pr2_vec),64,nthreads*sizeof(float*));\n",
1487+
" posix_memalign((void**)(&pr2_vec),64,sizeof(float*)*(long)(nthreads));\n",
14871488
" float *restrict r0_vec __attribute__ ((aligned (64)));\n",
1488-
" posix_memalign((void**)(&r0_vec),64,x_size*y_size*z_size*sizeof(float));\n",
1489+
" posix_memalign((void**)(&r0_vec),64,sizeof(float)*(long)(z_size)*(long)(y_size)*(long)(x_size));\n",
14891490
" #pragma omp parallel num_threads(nthreads)\n",
14901491
" {\n",
14911492
" const int tid = omp_get_thread_num();\n",
1492-
" posix_memalign((void**)(&(pr2_vec[tid])),64,z_size*(y_size + 4)*sizeof(float));\n",
1493+
" posix_memalign((void**)(&(pr2_vec[tid])),64,sizeof(float)*(long)(z_size)*(4 + (long)(y_size)));\n",
14931494
" }\n",
14941495
"\n",
14951496
" float (*restrict f)[f_vec->size[1]][f_vec->size[2]] __attribute__ ((aligned (64))) = (float (*)[f_vec->size[1]][f_vec->size[2]]) f_vec->data;\n",
@@ -1626,11 +1627,11 @@
16261627
"int Kernel(struct dataobj *restrict f_vec, struct dataobj *restrict u_vec, const float h_x, const float h_y, const int time_M, const int time_m, const int x0_blk0_size, const int x1_blk0_size, const int x_M, const int x_m, const int y0_blk0_size, const int y1_blk0_size, const int y_M, const int y_m, const int z_M, const int z_m, const int nthreads, const int x_size, const int y_size, const int z_size, struct profiler * timers)\n",
16271628
"{\n",
16281629
" float *restrict r0_vec __attribute__ ((aligned (64)));\n",
1629-
" posix_memalign((void**)(&r0_vec),64,x_size*y_size*z_size*sizeof(float));\n",
1630+
" posix_memalign((void**)(&r0_vec),64,sizeof(float)*(long)(z_size)*(long)(y_size)*(long)(x_size));\n",
16301631
" float *restrict r3_vec __attribute__ ((aligned (64)));\n",
1631-
" posix_memalign((void**)(&r3_vec),64,z_size*(x_size + 4)*(y_size + 4)*sizeof(float));\n",
1632+
" posix_memalign((void**)(&r3_vec),64,sizeof(float)*(long)(z_size)*(4 + (long)(y_size))*(4 + (long)(x_size)));\n",
16321633
" float *restrict r4_vec __attribute__ ((aligned (64)));\n",
1633-
" posix_memalign((void**)(&r4_vec),64,z_size*(x_size + 4)*(y_size + 4)*sizeof(float));\n",
1634+
" posix_memalign((void**)(&r4_vec),64,sizeof(float)*(long)(z_size)*(4 + (long)(y_size))*(4 + (long)(x_size)));\n",
16341635
"\n",
16351636
" float (*restrict f)[f_vec->size[1]][f_vec->size[2]] __attribute__ ((aligned (64))) = (float (*)[f_vec->size[1]][f_vec->size[2]]) f_vec->data;\n",
16361637
" float (*restrict r0)[y_size][z_size] __attribute__ ((aligned (64))) = (float (*)[y_size][z_size]) r0_vec;\n",

0 commit comments

Comments
 (0)