Skip to content

Commit

Permalink
Merge pull request #154 from OP-DSL/fix/python3
Browse files Browse the repository at this point in the history
Python3 conversion of codegen
  • Loading branch information
gihanmudalige authored Nov 8, 2021
2 parents d5f6fe7 + cf486c2 commit ea03ab3
Show file tree
Hide file tree
Showing 12 changed files with 26 additions and 16 deletions.
4 changes: 2 additions & 2 deletions ops_translator/c/ops.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env python2.7
#!/usr/bin/env python3

# Open source copyright declaration based on BSD open source template:
# http://www.opensource.org/licenses/bsd-license.php
Expand Down Expand Up @@ -643,7 +643,7 @@ def main(source_files):
repeat = True
which_file = nk
else:
print('repeated kernel with incompatible arguments: ERROR' + kernels[nk]['name'])
print(('repeated kernel with incompatible arguments: ERROR' + kernels[nk]['name']))
break


Expand Down
5 changes: 3 additions & 2 deletions ops_translator/c/ops_gen_mpi_cuda.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@

import re
import datetime
import errno
import os
import glob

Expand Down Expand Up @@ -97,7 +98,7 @@ def ops_gen_mpi_cuda(master, date, consts, kernels, soa_set):
try:
os.makedirs('./CUDA')
except OSError as e:
if e.errno != os.errno.EEXIST:
if e.errno != errno.EEXIST:
raise
for nk in range (0,len(kernels)):
arg_typ = kernels[nk]['arg_type']
Expand Down Expand Up @@ -694,7 +695,7 @@ def ops_gen_mpi_cuda(master, date, consts, kernels, soa_set):
code('')

for n in range (0, nargs):
if arg_typ[n] == 'ops_arg_gbl' and accs[n] <> OPS_READ:
if arg_typ[n] == 'ops_arg_gbl' and accs[n] != OPS_READ:
code('arg'+str(n)+'.data = block->instance->OPS_reduct_h + reduct_bytes;')
code('arg'+str(n)+'.data_d = block->instance->OPS_reduct_d + reduct_bytes;')
code('for (int b=0; b<maxblocks; b++)')
Expand Down
3 changes: 2 additions & 1 deletion ops_translator/c/ops_gen_mpi_hip.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@

import re
import datetime
import errno
import os
import glob

Expand Down Expand Up @@ -676,7 +677,7 @@ def ops_gen_mpi_hip(master, date, consts, kernels, soa_set):
code('')

for n in range (0, nargs):
if arg_typ[n] == 'ops_arg_gbl' and accs[n] <> OPS_READ:
if arg_typ[n] == 'ops_arg_gbl' and accs[n] != OPS_READ:
code('arg'+str(n)+'.data = block->instance->OPS_reduct_h + reduct_bytes;')
code('arg'+str(n)+'.data_d = block->instance->OPS_reduct_d + reduct_bytes;')
code('for (int b=0; b<maxblocks; b++)')
Expand Down
5 changes: 3 additions & 2 deletions ops_translator/c/ops_gen_mpi_inline.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@

import re
import datetime
import errno
import os
import glob

Expand Down Expand Up @@ -94,7 +95,7 @@ def ops_gen_mpi_inline(master, date, consts, kernels, soa_set):
try:
os.makedirs('./MPI_inline')
except OSError as e:
if e.errno != os.errno.EEXIST:
if e.errno != errno.EEXIST:
raise

##########################################################################
Expand Down Expand Up @@ -472,7 +473,7 @@ def ops_gen_mpi_inline(master, date, consts, kernels, soa_set):
try:
os.makedirs('./MPI_inline')
except OSError as e:
if e.errno != os.errno.EEXIST:
if e.errno != errno.EEXIST:
raise
fid = open('./MPI_inline/'+name+'_mpiinline_kernel_c.c','w')
date = datetime.datetime.now()
Expand Down
3 changes: 2 additions & 1 deletion ops_translator/c/ops_gen_mpi_lazy.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@

import re
import datetime
import errno
import os
import glob

Expand Down Expand Up @@ -108,7 +109,7 @@ def ops_gen_mpi_lazy(master, date, consts, kernels, soa_set):
try:
os.makedirs('./MPI_OpenMP')
except OSError as e:
if e.errno != os.errno.EEXIST:
if e.errno != errno.EEXIST:
raise

for nk in range (0,len(kernels)):
Expand Down
3 changes: 2 additions & 1 deletion ops_translator/c/ops_gen_mpi_openacc.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@

import re
import datetime
import errno
import os
import glob

Expand Down Expand Up @@ -97,7 +98,7 @@ def ops_gen_mpi_openacc(master, date, consts, kernels, soa_set):
try:
os.makedirs('./OpenACC')
except OSError as e:
if e.errno != os.errno.EEXIST:
if e.errno != errno.EEXIST:
raise
for nk in range (0,len(kernels)):
arg_typ = kernels[nk]['arg_type']
Expand Down
5 changes: 3 additions & 2 deletions ops_translator/c/ops_gen_mpi_opencl.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@

import re
import datetime
import errno
import os
import glob

Expand Down Expand Up @@ -107,7 +108,7 @@ def ops_gen_mpi_opencl(master, date, consts, kernels, soa_set):
try:
os.makedirs('./OpenCL')
except OSError as e:
if e.errno != os.errno.EEXIST:
if e.errno != errno.EEXIST:
raise
for nk in range (0,len(kernels)):
arg_typ = kernels[nk]['arg_type']
Expand Down Expand Up @@ -498,7 +499,7 @@ def ops_gen_mpi_opencl(master, date, consts, kernels, soa_set):
try:
os.makedirs('./OpenCL')
except OSError as e:
if e.errno != os.errno.EEXIST:
if e.errno != errno.EEXIST:
raise
fid = open('./OpenCL/'+name+'.cl','w')
date = datetime.datetime.now()
Expand Down
2 changes: 1 addition & 1 deletion ops_translator/fortran/ops_fortran.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3

# Open source copyright declaration based on BSD open source template:
# http://www.opensource.org/licenses/bsd-license.php
Expand Down
3 changes: 2 additions & 1 deletion ops_translator/fortran/ops_fortran_gen_mpi.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@

import re
import datetime
import errno
import os

import util_fortran
Expand Down Expand Up @@ -484,7 +485,7 @@ def ops_fortran_gen_mpi(master, date, consts, kernels):
try:
os.makedirs('./MPI')
except OSError as e:
if e.errno != os.errno.EEXIST:
if e.errno != errno.EEXIST:
raise
fid = open('./MPI/'+name+'_seq_kernel.F90','w')
date = datetime.datetime.now()
Expand Down
3 changes: 2 additions & 1 deletion ops_translator/fortran/ops_fortran_gen_mpi_cuda.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@

import re
import datetime
import errno
import os

import util_fortran
Expand Down Expand Up @@ -1099,7 +1100,7 @@ def ops_fortran_gen_mpi_cuda(master, date, consts, kernels):
try:
os.makedirs('./CUDA')
except OSError as e:
if e.errno != os.errno.EEXIST:
if e.errno != errno.EEXIST:
raise
fid = open('./CUDA/'+name+'_cuda_kernel.CUF','w')
date = datetime.datetime.now()
Expand Down
3 changes: 2 additions & 1 deletion ops_translator/fortran/ops_fortran_gen_mpi_openacc.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@

import re
import datetime
import errno
import os

import util_fortran
Expand Down Expand Up @@ -565,7 +566,7 @@ def ops_fortran_gen_mpi_openacc(master, date, consts, kernels):
try:
os.makedirs('./MPI_OpenACC')
except OSError as e:
if e.errno != os.errno.EEXIST:
if e.errno != errno.EEXIST:
raise
fid = open('./MPI_OpenACC/'+name+'_openacc_kernel.F90','w')
date = datetime.datetime.now()
Expand Down
3 changes: 2 additions & 1 deletion ops_translator/fortran/ops_fortran_gen_mpi_openmp.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
"""

import re
import errno
import datetime
import os

Expand Down Expand Up @@ -515,7 +516,7 @@ def ops_fortran_gen_mpi_openmp(master, date, consts, kernels):
try:
os.makedirs('./MPI_OpenMP')
except OSError as e:
if e.errno != os.errno.EEXIST:
if e.errno != errno.EEXIST:
raise
fid = open('./MPI_OpenMP/'+name+'_omp_kernel.F90','w')
date = datetime.datetime.now()
Expand Down

0 comments on commit ea03ab3

Please sign in to comment.