Skip to content

Commit

Permalink
#174 change to generate code for new FortCL interface [skip ci]
Browse files Browse the repository at this point in the history
  • Loading branch information
arporter committed Jul 20, 2018
1 parent 92b3319 commit 5b1b707
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
14 changes: 8 additions & 6 deletions src/psyclone/gocean1p0.py
Original file line number Diff line number Diff line change
Expand Up @@ -790,8 +790,8 @@ def gen_ocl(self, parent):

kernel = "kernel_" + self._name # TODO use namespace manager

parent.add(UseGen(parent, name="ocl_env_mod", only=True,
funcnames=["create_buffer"]))
parent.add(UseGen(parent, name="fortcl", only=True,
funcnames=["create_rw_buffer"]))
# Ensure fields are on device TODO this belongs somewhere else!
parent.add(CommentGen(parent,
" Ensure field data is on device"))
Expand All @@ -815,16 +815,18 @@ def gen_ocl(self, parent):
parent.add(DeclGen(parent, datatype="integer",
kind="c_intptr_t", target=True,
entity_decls=["write_event"]))

size_expr = "int({0}%grid%nx*{0}%grid%ny, 8)*c_sizeof({1}(1,1))".\
format(garg.name, host_buff)
# Use c_sizeof() on first element of array to be copied over in
# order to cope with the fact that some grid properties are
# integer.
size_expr = ("int({0}%grid%nx*{0}%grid%ny, 8)*"
"c_sizeof({1}(1,1))".format(garg.name, host_buff))
ifthen.add(AssignGen(ifthen, lhs="size_in_bytes",
rhs=size_expr))
ifthen.add(CommentGen(ifthen, " Create buffer on device"))

ifthen.add(AssignGen(
ifthen, lhs=device_buff,
rhs="create_buffer(CL_MEM_READ_WRITE, size_in_bytes)"))
rhs="create_rw_buffer(size_in_bytes)"))
ifthen.add(AssignGen(
ifthen, lhs="ierr",
rhs="clEnqueueWriteBuffer(cmd_queues(1), {0}, "
Expand Down
4 changes: 2 additions & 2 deletions src/psyclone/psyGen.py
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,7 @@ def gen_ocl_init(self, parent, kernels):
CallGen, UseGen, CommentGen, CharDeclGen, IfThenGen
sub = SubroutineGen(parent, "psy_init")
parent.add(sub)
sub.add(UseGen(sub, name="ocl_env_mod", only=True,
sub.add(UseGen(sub, name="fortcl", only=True,
funcnames=["ocl_env_init", "add_kernels"]))
# Add a logical variable used to ensure that this routine is only
# executed once.
Expand Down Expand Up @@ -1423,7 +1423,7 @@ def gen_code(self, parent):
if self._opencl:
parent.add(UseGen(parent, name="iso_c_binding"))
parent.add(UseGen(parent, name="clfortran"))
parent.add(UseGen(parent, name="ocl_env_mod", only=True,
parent.add(UseGen(parent, name="fortcl", only=True,
funcnames=["get_num_cmd_queues",
"get_cmd_queues",
"get_kernel_by_name"]))
Expand Down

0 comments on commit 5b1b707

Please sign in to comment.