Skip to content

Commit 1feccb1

Browse files
committed
Modify OpenMP kernel test
1 parent 6e095b0 commit 1feccb1

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

test/test_xcpp_kernel.py

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -238,13 +238,27 @@ class BaseXCppOpenMPTests(jupyter_kernel_test.KernelTests):
238238
#include <iostream>
239239
#include <clang/Interpreter/CppInterOp.h>
240240
Cpp::LoadLibrary("libomp");
241-
printf("all done, with hopefully threads\n");
241+
int main() {
242+
omp_set_num_threads(2);
243+
#pragma omp parallel
244+
{
245+
if (omp_get_thread_num() == 1) {
246+
printf("1");
247+
#pragma omp barrier
248+
}
249+
else if (omp_get_thread_num() == 0) {
250+
#pragma omp barrier
251+
printf("0");
252+
}
253+
}
254+
}
255+
main();
242256
"""
243257

244258
def test_xcpp_omp(self):
245259
self.flush_channels()
246260
reply, output_msgs = self.execute_helper(code=self.code_omp,timeout=20)
247-
self.assertEqual(output_msgs[0]['content']['name'], 'stdout')
261+
self.assertEqual(output_msgs[0]['content']['text'], '10\n')
248262

249263
kernel_names = ['xcpp17-omp', 'xcpp20-omp', 'xcpp23-omp']
250264

0 commit comments

Comments
 (0)