Skip to content

Commit 5d3cb03

Browse files
committed
Fixed a bug in generating the code.
1 parent 8360487 commit 5d3cb03

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

kernel_tuner/utils/directives.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -560,6 +560,8 @@ def add_present_openacc(
560560
elif is_fortran(langs.language):
561561
present_clause += add_present_openacc_fortran(name, size)
562562
new_body += new_line + present_clause.rstrip() + "\n"
563+
if new_body.rfind("\n") != len(new_body) - 1:
564+
new_body += "\n"
563565
return new_body
564566

565567

test/utils/test_directives.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -308,11 +308,13 @@ def test_extract_initialization_code():
308308
def test_add_present_openacc():
309309
acc_cxx = Code(OpenACC(), Cxx())
310310
acc_f90 = Code(OpenACC(), Fortran())
311-
code_cxx = "#pragma acc parallel num_gangs(32)\n"
311+
code_cxx = "#pragma acc parallel num_gangs(32)\n#pragma acc\n"
312312
code_f90 = "!$acc parallel async num_workers(16)\n"
313313
data = {"array": ["int*", "size"]}
314314
preprocessor = ["#define size 42"]
315-
expected_cxx = "#pragma acc parallel num_gangs(32) present(array[:42])\n"
315+
expected_cxx = "#pragma acc parallel num_gangs(32) present(array[:42])\n#pragma acc\n"
316316
assert add_present_openacc(code_cxx, acc_cxx, data, preprocessor, None) == expected_cxx
317317
expected_f90 = "!$acc parallel async num_workers(16) present(array(:42))\n"
318318
assert add_present_openacc(code_f90, acc_f90, data, preprocessor, None) == expected_f90
319+
code_f90 = "!$acc parallel async num_workers(16) copy(array(:42))\n"
320+
assert add_present_openacc(code_f90, acc_f90, data, preprocessor, None) == code_f90

0 commit comments

Comments
 (0)