Skip to content

Commit

Permalink
compiler: Polish code generation
Browse files Browse the repository at this point in the history
  • Loading branch information
FabioLuporini committed Jul 26, 2022
1 parent 0a1f2df commit d29d57d
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 8 deletions.
7 changes: 6 additions & 1 deletion devito/ir/iet/visitors.py
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,12 @@ def visit_Definition(self, o):
if o.constructor_args:
v = MultilineCall(v, o.constructor_args, True)

v = c.Value(f._C_typename, v)
# Aesthetics: `float * a` -> `float *a`
try:
t, stars = f._C_typename.split()
v = c.Value(t, '%s%s' % (stars, v))
except ValueError:
v = c.Value(f._C_typename, v)

if o.initvalue is not None:
v = c.Initializer(v, o.initvalue)
Expand Down
2 changes: 2 additions & 0 deletions devito/types/parallel.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,8 @@ class ThreadID(CustomDimension):
__rargs__ = ('nthreads',)
__rkwargs__ = ()

is_const = True

def __new__(cls, nthreads):
return CustomDimension.__new__(cls, name='tid', symbolic_size=nthreads)

Expand Down
4 changes: 2 additions & 2 deletions examples/mpi/overview.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -1025,9 +1025,9 @@
"\n",
"static void sendrecv0(struct dataobj *restrict u_vec, const int x_size, const int y_size, int ogtime, int ogx, int ogy, int ostime, int osx, int osy, int fromrank, int torank, MPI_Comm comm)\n",
"{\n",
" float * bufg_vec;\n",
" float *bufg_vec;\n",
" posix_memalign((void**)(&bufg_vec),64,x_size*y_size*sizeof(float));\n",
" float * bufs_vec;\n",
" float *bufs_vec;\n",
" posix_memalign((void**)(&bufs_vec),64,x_size*y_size*sizeof(float));\n",
"\n",
" MPI_Request rrecv;\n",
Expand Down
10 changes: 5 additions & 5 deletions examples/performance/00_overview.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -1219,7 +1219,7 @@
"{\n",
" float **pr2_vec;\n",
" posix_memalign((void**)(&pr2_vec),64,nthreads*sizeof(float*));\n",
" float * r0_vec;\n",
" float *r0_vec;\n",
" posix_memalign((void**)(&r0_vec),64,x_size*y_size*z_size*sizeof(float));\n",
" #pragma omp parallel num_threads(nthreads)\n",
" {\n",
Expand Down Expand Up @@ -1510,7 +1510,7 @@
"{\n",
" float **pr2_vec;\n",
" posix_memalign((void**)(&pr2_vec),64,nthreads*sizeof(float*));\n",
" float * r0_vec;\n",
" float *r0_vec;\n",
" posix_memalign((void**)(&r0_vec),64,x_size*y_size*z_size*sizeof(float));\n",
" #pragma omp parallel num_threads(nthreads)\n",
" {\n",
Expand Down Expand Up @@ -1655,11 +1655,11 @@
"\n",
"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",
"{\n",
" float * r0_vec;\n",
" float *r0_vec;\n",
" posix_memalign((void**)(&r0_vec),64,x_size*y_size*z_size*sizeof(float));\n",
" float * r3_vec;\n",
" float *r3_vec;\n",
" posix_memalign((void**)(&r3_vec),64,z_size*(x_size + 4)*(y_size + 4)*sizeof(float));\n",
" float * r4_vec;\n",
" float *r4_vec;\n",
" posix_memalign((void**)(&r4_vec),64,z_size*(x_size + 4)*(y_size + 4)*sizeof(float));\n",
"\n",
" 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",
Expand Down

0 comments on commit d29d57d

Please sign in to comment.