File tree Expand file tree Collapse file tree 1 file changed +48
-0
lines changed Expand file tree Collapse file tree 1 file changed +48
-0
lines changed Original file line number Diff line number Diff line change @@ -225,5 +225,53 @@ class BaseXCppTests2(jupyter_kernel_test.KernelTests):
225225 }
226226 )
227227
228+ if platform .system () != 'Windows' :
229+ class BaseXCppOpenMPTests (jupyter_kernel_test .KernelTests ):
230+ __test__ = False
231+
232+ # language_info.name in a kernel_info_reply should match this
233+ language_name = 'C++'
234+
235+ # Code that should write the exact string `hello, world` to STDOUT
236+ code_omp = """
237+ #include <omp.h>
238+ #include <iostream>
239+ #include <clang/Interpreter/CppInterOp.h>
240+ Cpp::LoadLibrary("libomp");
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();
256+ """
257+
258+ def test_xcpp_omp (self ):
259+ self .flush_channels ()
260+ reply , output_msgs = self .execute_helper (code = self .code_omp ,timeout = 20 )
261+ self .assertEqual (output_msgs [0 ]['content' ]['text' ], '10\n ' )
262+
263+ kernel_names = ['xcpp17-omp' , 'xcpp20-omp' , 'xcpp23-omp' ]
264+
265+ for name in kernel_names :
266+ class_name = f"XCppOpenMPTests_{ name } "
267+ globals ()[class_name ] = type (
268+ class_name ,
269+ (BaseXCppOpenMPTests ,),
270+ {
271+ 'kernel_name' : name ,
272+ '__test__' : True
273+ }
274+ )
275+
228276if __name__ == '__main__' :
229277 unittest .main ()
You can’t perform that action at this time.
0 commit comments