10 extern void *ompd_library
;
12 struct _ompd_aspace_cont
{
15 struct _ompd_thread_cont
{
18 ompd_address_space_context_t context
= {42};
19 ompd_address_space_context_t invalidcontext
= {99};
21 // call back functions for ompd_initialize
22 ompd_rc_t
_alloc(ompd_size_t bytes
, void **ptr
);
23 ompd_rc_t
_free(void *ptr
);
24 ompd_rc_t
_sizes(ompd_address_space_context_t
*_acontext
,
25 ompd_device_type_sizes_t
*sizes
);
26 ompd_rc_t
_sym_addr(ompd_address_space_context_t
*context
,
27 ompd_thread_context_t
*tcontext
, const char *symbol_name
,
28 ompd_address_t
*symbol_addr
, const char *file_name
);
29 ompd_rc_t
_read(ompd_address_space_context_t
*context
,
30 ompd_thread_context_t
*tcontext
, const ompd_address_t
*addr
,
31 ompd_size_t nbytes
, void *buffer
);
32 ompd_rc_t
_read_string(ompd_address_space_context_t
*context
,
33 ompd_thread_context_t
*tcontext
,
34 const ompd_address_t
*addr
, ompd_size_t nbytes
,
36 ompd_rc_t
_endianess(ompd_address_space_context_t
*address_space_context
,
37 const void *input
, ompd_size_t unit_size
,
38 ompd_size_t count
, void *output
);
39 ompd_rc_t
_thread_context(ompd_address_space_context_t
*context
,
40 ompd_thread_id_t kind
, ompd_size_t sizeof_thread_id
,
41 const void *thread_id
,
42 ompd_thread_context_t
**thread_context
);
43 ompd_rc_t
_print(const char *str
, int category
);
46 Test API: ompd_get_thread_handle
48 ompdtestapi threadandparallel
54 4. omp_set_num_threads(2);
55 5. #pragma omp parallel
57 7. printf("Parallel level 1, thread num = %d",
58 omp_get_thread_num());
67 ompdtestapi ompd_get_thread_handle
69 for ompd_rc_unavailable:
71 ompdtestapi ompd_get_thread_handle
74 PyObject
*test_ompd_get_thread_handle(PyObject
*self
, PyObject
*args
) {
75 printf("Testing \"ompd_get_thread_handle\"...\n");
77 PyObject
*addrSpaceTup
= PyTuple_GetItem(args
, 0);
78 ompd_address_space_handle_t
*addr_handle
=
79 (ompd_address_space_handle_t
*)PyCapsule_GetPointer(addrSpaceTup
,
82 PyObject
*threadIdTup
= PyTuple_GetItem(args
, 1);
83 uint64_t threadID
= (uint64_t)PyLong_AsLong(threadIdTup
);
85 ompd_size_t sizeof_thread_id
= sizeof(threadID
);
86 ompd_thread_handle_t
*thread_handle
;
88 // should be successful
89 printf("Test: With Correct Arguments.\n");
90 ompd_rc_t rc
= ompd_get_thread_handle(
91 addr_handle
, 1 /*lwp*/, sizeof_thread_id
, &threadID
, &thread_handle
);
93 if (rc
== ompd_rc_unavailable
) {
94 // ompd_rc_unavailable if the thread is not an OpenMP thread.
95 printf("Success. ompd_rc_unavailable, OpenMP is disabled.\n");
96 printf("This is not a Parallel Region, No more testing is possible.\n");
98 } else if (rc
!= ompd_rc_ok
)
99 printf("Failed, with return code = %d\n", rc
);
101 printf("Success.\n");
103 // as in ompd-types.h, only 0-3 are valid for thread kind
104 // ompd_rc_unsupported if thread kind is not supported.
105 printf("Test: Unsupported thread kind.\n");
106 rc
= ompd_get_thread_handle(addr_handle
, 4, sizeof_thread_id
, &threadID
,
108 if (rc
!= ompd_rc_unsupported
)
109 printf("Failed, with return code = %d\n", rc
);
111 printf("Success.\n");
113 // ompd_rc_bad_input: if a different value in sizeof_thread_id is expected for
115 // sizeof_thread_id is validated at thread_context which is call back function
116 // "_thread_context" where we expect size to be sizeof(long int)
117 printf("Test: Wrong value for sizeof threadID.\n");
118 rc
= ompd_get_thread_handle(addr_handle
, 1 /*lwp*/, sizeof_thread_id
- 1,
119 &threadID
, &thread_handle
);
120 if (rc
!= ompd_rc_bad_input
)
121 printf("Failed, with return code = %d\n", rc
);
123 printf("Success.\n");
125 // Random checks with null and invalid args.
127 ompd_rc_stale_handle: is returned when the specified handle is no
129 ompd_rc_bad_input: is returned when the input parameters
130 (other than handle) are invalid;
131 ompd_rc_error: is returned when a fatal error occurred;
134 printf("Test: Expecting ompd_rc_bad_input for NULL thread_handle.\n");
135 rc
= ompd_get_thread_handle(addr_handle
, 1 /*lwp*/, sizeof_thread_id
,
137 if (rc
!= ompd_rc_bad_input
)
138 printf("Failed, with return code = %d\n", rc
);
140 printf("Success.\n");
143 "Test: Expecting ompd_rc_error or stale_handle for NULL addr_handle.\n");
144 rc
= ompd_get_thread_handle(NULL
, 1 /*lwp*/, sizeof_thread_id
, &threadID
,
146 if (rc
!= ompd_rc_error
&& rc
!= ompd_rc_stale_handle
)
147 printf("Failed, with return code = %d\n", rc
);
149 printf("Success.\n");
155 Test API: ompd_get_curr_parallel_handle.
158 1. #include <stdio.h>
161 4. omp_set_num_threads(2);
162 5. #pragma omp parallel
164 7. printf("Parallel level 1, thread num = %d",
165 omp_get_thread_num());
173 omptestapi ompd_get_curr_parallel_handle
175 for ompd_rc_unavailable
177 omptestapi ompd_get_curr_parallel_handle (or break at line 4
181 PyObject
*test_ompd_get_curr_parallel_handle(PyObject
*self
, PyObject
*args
) {
182 printf("Testing \"ompd_get_curr_parallel_handle\"...\n");
184 PyObject
*threadHandlePy
= PyTuple_GetItem(args
, 0);
185 ompd_thread_handle_t
*thread_handle
=
186 (ompd_thread_handle_t
*)(PyCapsule_GetPointer(threadHandlePy
,
189 ompd_parallel_handle_t
*parallel_handle
;
191 printf("Test: With Correct Arguments.\n");
192 ompd_rc_t rc
= ompd_get_curr_parallel_handle(thread_handle
, ¶llel_handle
);
193 if (rc
== ompd_rc_unavailable
) {
194 // ompd_rc_unavailable if the thread is not currently part of a team
196 // ToCheck: Even in non parallel region, error code is stale_handle
197 // Need to find a test case for ompd_rc_unavailable ?????
198 printf("Success. ompd_rc_unavailable, Not in parallel region\n");
199 printf("No more testing is possible.\n");
201 } else if (rc
== ompd_rc_stale_handle
) {
202 printf("Return code is stale_handle, may be in non-parallel region.\n");
203 printf("No more testing is possible.\n");
205 } else if (rc
!= ompd_rc_ok
)
206 printf("Failed, with return code = %d\n", rc
);
208 printf("Success.\n");
210 // Random checks with null and invalid args.
212 ompd_rc_stale_handle: is returned when the specified handle is no
214 ompd_rc_bad_input: is returned when the input parameters
215 (other than handle) are invalid;
216 ompd_rc_error: is returned when a fatal error occurred;
219 printf("Test: Expecting ompd_rc_bad_input for NULL parallel_handle.\n");
220 rc
= ompd_get_curr_parallel_handle(thread_handle
, NULL
);
221 if (rc
!= ompd_rc_bad_input
)
222 printf("Failed, with return code = %d\n", rc
);
224 printf("Success.\n");
226 printf("Test: Expecting ompd_rc_error or stale_handle for NULL "
228 rc
= ompd_get_curr_parallel_handle(NULL
, ¶llel_handle
);
229 if (rc
!= ompd_rc_error
&& rc
!= ompd_rc_stale_handle
)
230 printf("Failed, with return code = %d\n", rc
);
232 printf("Success.\n");
238 Test API: ompd_get_thread_in_parallel.
241 1. #include <stdio.h>
244 4. omp_set_num_threads(3);
245 5. #pragma omp parallel
247 7. printf("Parallel level 1, thread num = %d",
248 omp_get_thread_num());
256 omptestapi ompd_get_thread_in_parallel
258 PyObject
*test_ompd_get_thread_in_parallel(PyObject
*self
, PyObject
*args
) {
259 printf("Testing \"ompd_get_thread_in_parallel\"...\n");
261 PyObject
*parallelHandlePy
= PyTuple_GetItem(args
, 0);
262 ompd_parallel_handle_t
*parallel_handle
=
263 (ompd_parallel_handle_t
*)(PyCapsule_GetPointer(parallelHandlePy
,
265 ompd_thread_handle_t
*thread_handle
;
267 printf("Test: With Correct Arguments.\n");
268 ompd_rc_t rc
= ompd_get_thread_in_parallel(
269 parallel_handle
, 1 /* lesser than team-size-var*/, &thread_handle
);
270 if (rc
!= ompd_rc_ok
) {
271 printf("Failed, with return code = %d\n", rc
);
274 printf("Success.\n");
276 // ompd_rc_bad_input: if the thread_num argument is greater than or equal to
277 // the team-size-var ICV or negative
278 printf("Test: Invalid thread num (199).\n");
279 rc
= ompd_get_thread_in_parallel(parallel_handle
, 199, &thread_handle
);
280 if (rc
!= ompd_rc_bad_input
)
281 printf("Failed, with return code = %d\n", rc
);
283 printf("Success.\n");
285 printf("Test: Invalid thread num (-5).\n");
286 rc
= ompd_get_thread_in_parallel(parallel_handle
, -5, &thread_handle
);
287 if (rc
!= ompd_rc_bad_input
)
288 printf("Failed, with return code = %d\n", rc
);
290 printf("Success.\n");
292 // Random checks with null and invalid args.
294 ompd_rc_stale_handle: is returned when the specified handle is no
296 ompd_rc_bad_input: is returned when the input parameters
297 (other than handle) are invalid;
298 ompd_rc_error: is returned when a fatal error occurred;
301 printf("Test: Expecting ompd_rc_bad_input for NULL thread_handle.\n");
302 rc
= ompd_get_thread_in_parallel(parallel_handle
, 1, NULL
);
303 if (rc
!= ompd_rc_bad_input
)
304 printf("Failed, with return code = %d\n", rc
);
306 printf("Success.\n");
308 printf("Test: Expecting ompd_rc_error or stale_handle for NULL "
309 "parallel_handle.\n");
310 rc
= ompd_get_thread_in_parallel(NULL
, 1, &thread_handle
);
311 if (rc
!= ompd_rc_error
&& rc
!= ompd_rc_stale_handle
)
312 printf("Failed, with return code = %d\n", rc
);
314 printf("Success.\n");
320 Test API: ompd_thread_handle_compare.
323 1. #include <stdio.h>
326 4. omp_set_num_threads(4);
327 5. #pragma omp parallel
329 7. printf("Parallel level 1, thread num = %d",
330 omp_get_thread_num());
338 omptestapi ompd_thread_handle_compare
341 PyObject
*test_ompd_thread_handle_compare(PyObject
*self
, PyObject
*args
) {
342 printf("Testing \"ompd_thread_handle_compare\"...\n");
344 PyObject
*threadHandlePy1
= PyTuple_GetItem(args
, 0);
345 ompd_thread_handle_t
*thread_handle1
=
346 (ompd_thread_handle_t
*)(PyCapsule_GetPointer(threadHandlePy1
,
348 PyObject
*threadHandlePy2
= PyTuple_GetItem(args
, 1);
349 ompd_thread_handle_t
*thread_handle2
=
350 (ompd_thread_handle_t
*)(PyCapsule_GetPointer(threadHandlePy2
,
355 printf("Test: With Correct Arguments.\n");
357 ompd_thread_handle_compare(thread_handle1
, thread_handle2
, &cmp_value
);
358 if (rc
!= ompd_rc_ok
) {
359 printf("Failed, with return code = %d\n", rc
);
362 printf("Success.\n");
364 if (cmp_value
== 0) {
365 printf("Threads are Equal.\n");
367 // a value less than, equal to, or greater than 0 indicates that the thread
368 // corresponding to thread_handle_1 is, respectively, less than, equal to,
369 // or greater than that corresponding to thread_handle_2.
370 if (cmp_value
<= 0) {
371 printf("Thread 1 is lesser than thread 2, cmp_val = %d\n", cmp_value
);
372 printf("Test: Changing the order.\n");
373 rc
= ompd_thread_handle_compare(thread_handle2
, thread_handle1
,
375 if (rc
!= ompd_rc_ok
) {
376 printf("Failed, with return code = %d\n", rc
);
380 printf("Success now cmp_value is greater, %d.\n", cmp_value
);
384 printf("Thread 1 is greater than thread 2.\n");
385 printf("Test: Changing the order.\n");
386 rc
= ompd_thread_handle_compare(thread_handle2
, thread_handle1
,
388 if (rc
!= ompd_rc_ok
) {
389 printf("Failed, with return code = %d\n", rc
);
393 printf("Success now cmp_value is lesser, %d.\n", cmp_value
);
398 // Random checks with null and invalid args.
400 ompd_rc_stale_handle: is returned when the specified handle is no
402 ompd_rc_bad_input: is returned when the input parameters
403 (other than handle) are invalid;
404 ompd_rc_error: is returned when a fatal error occurred;
407 printf("Test: Expecting ompd_rc_bad_input for NULL cmp_value.\n");
408 rc
= ompd_thread_handle_compare(thread_handle2
, thread_handle1
, NULL
);
409 if (rc
!= ompd_rc_bad_input
)
410 printf("Failed, with return code = %d\n", rc
);
412 printf("Success.\n");
414 printf("Test: Expecting ompd_rc_error or stale_handle for NULL "
416 rc
= ompd_thread_handle_compare(NULL
, thread_handle1
, &cmp_value
);
417 if (rc
!= ompd_rc_error
&& rc
!= ompd_rc_stale_handle
)
418 printf("Failed, with return code = %d\n", rc
);
420 printf("Success.\n");
427 Test API: ompd_get_thread_id.
430 1. #include <stdio.h>
433 4. omp_set_num_threads(2);
434 5. #pragma omp parallel
436 7. printf("Parallel level 1, thread num = %d",
437 omp_get_thread_num());
445 omptestapi ompd_get_thread_id
448 PyObject
*test_ompd_get_thread_id(PyObject
*self
, PyObject
*args
) {
449 printf("Testing \"ompd_get_thread_id\"...\n");
451 PyObject
*threadHandlePy
= PyTuple_GetItem(args
, 0);
452 ompd_thread_handle_t
*thread_handle
=
453 (ompd_thread_handle_t
*)(PyCapsule_GetPointer(threadHandlePy
,
457 ompd_size_t sizeof_thread_id
= sizeof(threadID
);
459 printf("Test: With Correct Arguments.\n");
460 ompd_rc_t rc
= ompd_get_thread_id(thread_handle
, 0 /*OMPD_THREAD_ID_PTHREAD*/,
461 sizeof_thread_id
, &threadID
);
462 if (rc
!= ompd_rc_ok
) {
463 printf("Failed, with return code = %d\n", rc
);
466 printf("Success. Thread id = %ld\n", threadID
);
468 // ompd_rc_bad_input: if a different value in sizeof_thread_id is expected for
469 // a thread kind of kind
470 printf("Test: Wrong sizeof_thread_id.\n");
471 rc
= ompd_get_thread_id(thread_handle
, 0 /*OMPD_THREAD_ID_PTHREAD*/,
472 sizeof_thread_id
- 1, &threadID
);
473 if (rc
!= ompd_rc_bad_input
)
474 printf("Failed, with return code = %d\n", rc
);
476 printf("Success.\n");
478 // ompd_rc_unsupported: if the kind of thread is not supported
479 printf("Test: Unsupported thread kind.\n");
480 // thread kind currently support from 0-3, refer in ompd-types.h
481 rc
= ompd_get_thread_id(thread_handle
, 4, sizeof_thread_id
- 1, &threadID
);
482 if (rc
!= ompd_rc_unsupported
)
483 printf("Failed, with return code = %d\n", rc
);
485 printf("Success.\n");
487 // Random checks with null and invalid args.
489 ompd_rc_stale_handle: is returned when the specified handle is no
491 ompd_rc_bad_input: is returned when the input parameters
492 (other than handle) are invalid;
493 ompd_rc_error: is returned when a fatal error occurred;
496 printf("Test: Expecting ompd_rc_bad_input for NULL threadID.\n");
497 rc
= ompd_get_thread_id(thread_handle
, 0 /*OMPD_THREAD_ID_PTHREAD*/,
498 sizeof_thread_id
, NULL
);
499 if (rc
!= ompd_rc_bad_input
)
500 printf("Failed, with return code = %d\n", rc
);
502 printf("Success.\n");
504 printf("Test: Expecting ompd_rc_error for NULL thread_handle.\n");
505 rc
= ompd_get_thread_id(NULL
, 0 /*OMPD_THREAD_ID_PTHREAD*/, sizeof_thread_id
,
507 if (rc
!= ompd_rc_error
&& rc
!= ompd_rc_stale_handle
)
508 printf("Failed, with return code = %d\n", rc
);
510 printf("Success.\n");
516 Test API: ompd_rel_thread_handle
519 1. #include <stdio.h>
522 4. omp_set_num_threads(2);
523 5. #pragma omp parallel
525 7. printf("Parallel level 1, thread num = %d",
526 omp_get_thread_num());
534 omptestapi ompd_rel_thread_handle
537 // TODO: This might not be the right way to do,as this handle comes from
538 // python not generated by ompd API
540 PyObject
*test_ompd_rel_thread_handle(PyObject
*self
, PyObject
*args
) {
541 printf("Testing Not enabled for \"ompd_rel_thread_handle\"...\n");
542 printf("Disabled.\n");
547 Test API: ompd_get_enclosing_parallel_handle.
550 1. #include <stdio.h>
553 4. omp_set_num_threads(2);
554 5. #pragma omp parallel
556 7. printf("Parallel level 1, thread num = %d",
557 omp_get_thread_num());
558 8. omp_set_num_threads(3);
559 9. #pragma omp parallel
561 11. printf ("Parallel level 2, thread num = %d",
562 omp_get_thread_num());
571 ompdtestapi ompd_get_enclosing_parallel_handle
573 for "ompd_rc_unavailable":
575 omptestapi ompd_get_enclosing_parallel_handle
576 (or break at line 4 before this)
579 PyObject
*test_ompd_get_enclosing_parallel_handle(PyObject
*self
,
581 printf("Testing \"ompd_get_enclosing_parallel_handle\"...\n");
583 PyObject
*parallelHandlePy
= PyTuple_GetItem(args
, 0);
584 ompd_parallel_handle_t
*parallel_handle
=
585 (ompd_parallel_handle_t
*)(PyCapsule_GetPointer(parallelHandlePy
,
587 ompd_parallel_handle_t
*enclosing_parallel_handle
;
589 printf("Test: With Correct Arguments.\n");
590 ompd_rc_t rc
= ompd_get_enclosing_parallel_handle(parallel_handle
,
591 &enclosing_parallel_handle
);
592 if (rc
== ompd_rc_unavailable
) {
593 // ompd_rc_unavailable: if no enclosing parallel region exists.
594 printf("Success. return code is ompd_rc_unavailable, Not in parallel "
596 printf("No more testing is possible.\n");
598 } else if (rc
!= ompd_rc_ok
) {
599 printf("Failed, with return code = %d\n", rc
);
602 printf("Success.\n");
604 // Random checks with null and invalid args.
606 ompd_rc_stale_handle: is returned when the specified handle is no
608 ompd_rc_bad_input: is returned when the input parameters
609 (other than handle) are invalid;
610 ompd_rc_error: is returned when a fatal error occurred;
613 printf("Test: Expecting ompd_rc_bad_input for NULL "
614 "enclosing_parallel_handle.\n");
615 rc
= ompd_get_enclosing_parallel_handle(parallel_handle
, NULL
);
616 if (rc
!= ompd_rc_bad_input
)
617 printf("Failed, with return code = %d\n", rc
);
619 printf("Success.\n");
621 printf("Test: Expecting ompd_rc_error or stale_handle for NULL "
622 "parallel_handle.\n");
623 rc
= ompd_get_enclosing_parallel_handle(NULL
, &enclosing_parallel_handle
);
624 if (rc
!= ompd_rc_error
&& rc
!= ompd_rc_stale_handle
)
625 printf("Failed, with return code = %d\n", rc
);
627 printf("Success.\n");
633 Test API: ompd_parallel_handle_compare.
636 1. #include <stdio.h>
639 4. omp_set_num_threads(2);
640 5. #pragma omp parallel
642 7. printf("Parallel level 1, thread num = %d",
643 omp_get_thread_num());
644 8. omp_set_num_threads(3);
645 9. #pragma omp parallel
647 11. printf ("Parallel level 2, thread num = %d",
648 omp_get_thread_num());
657 ompdtestapi ompd_parallel_handle_compare
660 PyObject
*test_ompd_parallel_handle_compare(PyObject
*self
, PyObject
*args
) {
661 printf("Testing \"ompd_parallel_handle_compare\"...\n");
663 PyObject
*parallelHandlePy1
= PyTuple_GetItem(args
, 0);
664 ompd_parallel_handle_t
*parallel_handle1
=
665 (ompd_parallel_handle_t
*)(PyCapsule_GetPointer(parallelHandlePy1
,
667 PyObject
*parallelHandlePy2
= PyTuple_GetItem(args
, 1);
668 ompd_parallel_handle_t
*parallel_handle2
=
669 (ompd_parallel_handle_t
*)(PyCapsule_GetPointer(parallelHandlePy2
,
674 printf("Test: With Correct Arguments.\n");
675 ompd_rc_t rc
= ompd_parallel_handle_compare(parallel_handle1
,
676 parallel_handle2
, &cmp_value
);
677 if (rc
!= ompd_rc_ok
) {
678 printf("Failed, with return code = %d\n", rc
);
681 printf("Success.\n");
683 if (cmp_value
== 0) {
684 printf("Parallel regions are Same.\n");
686 // A value less than, equal to, or greater than 0 indicates that the region
687 // corresponding to parallel_handle_1 is, respectively, less than, equal to,
688 // or greater than that corresponding to parallel_handle_2
689 if (cmp_value
<= 0) {
690 printf("Parallel handle 1 is lesser than handle 2, cmp_val = %d\n",
692 printf("Test: Changing the order.\n");
693 rc
= ompd_parallel_handle_compare(parallel_handle2
, parallel_handle1
,
695 if (rc
!= ompd_rc_ok
) {
696 printf("Failed, with return code = %d\n", rc
);
700 printf("Success now cmp_value is greater, %d.\n", cmp_value
);
704 printf("Parallel 1 is greater than handle 2.\n");
705 printf("Test: Changing the order.\n");
706 rc
= ompd_parallel_handle_compare(parallel_handle2
, parallel_handle1
,
708 if (rc
!= ompd_rc_ok
) {
709 printf("Failed, with return code = %d\n", rc
);
713 printf("Success now cmp_value is lesser, %d.\n", cmp_value
);
718 // Random checks with null and invalid args.
720 ompd_rc_stale_handle: is returned when the specified handle is no
722 ompd_rc_bad_input: is returned when the input parameters
723 (other than handle) are invalid;
724 ompd_rc_error: is returned when a fatal error occurred;
727 printf("Test: Expecting ompd_rc_bad_input for NULL cmp_value.\n");
728 rc
= ompd_parallel_handle_compare(parallel_handle2
, parallel_handle1
, NULL
);
729 if (rc
!= ompd_rc_bad_input
)
730 printf("Failed, with return code = %d\n", rc
);
732 printf("Success.\n");
734 printf("Test: Expecting ompd_rc_error or stale_handle for NULL "
736 rc
= ompd_parallel_handle_compare(NULL
, parallel_handle1
, &cmp_value
);
737 if (rc
!= ompd_rc_error
&& rc
!= ompd_rc_stale_handle
)
738 printf("Failed, with return code = %d\n", rc
);
740 printf("Success.\n");
747 Test API: ompd_rel_parallel_handle
750 1. #include <stdio.h>
753 4. omp_set_num_threads(2);
754 5. #pragma omp parallel
756 7. printf("Parallel level 1, thread num = %d",
757 omp_get_thread_num());
765 omptestapi ompd_rel_parallel_handle
768 // TODO: Same as thread_rel_handle, might not be a right way to test
769 // What released should be provided by ompd API, this address is actually from
771 PyObject
*test_ompd_rel_parallel_handle(PyObject
*self
, PyObject
*args
) {
772 printf("Testing NOT enabled for \"ompd_rel_parallel_handle\"...\n");
773 printf("Disabled.\n");
778 Test API: ompd_initialize
781 1. #include <stdio.h>
784 4. omp_set_num_threads(2);
785 5. #pragma omp parallel
787 7. printf("Parallel level 1, thread num = %d",
788 omp_get_thread_num());
795 ompdtestapi ompd_initialize\
797 PyObject
*test_ompd_initialize(PyObject
*self
, PyObject
*noargs
) {
798 printf("Testing \"test_ompd_initialize\"...\n");
801 ompd_rc_t rc
= ompd_get_api_version(&version
);
802 if (rc
!= ompd_rc_ok
) {
803 printf("Failed in \"ompd_get_api_version\".\n");
807 static ompd_callbacks_t table
= {
808 _alloc
, _free
, _print
, _sizes
, _sym_addr
, _read
,
809 NULL
, _read_string
, _endianess
, _endianess
, _thread_context
};
811 printf("Test: With Correct Arguments.\n");
812 ompd_rc_t (*my_ompd_init
)(ompd_word_t version
, ompd_callbacks_t
*) =
813 dlsym(ompd_library
, "ompd_initialize");
814 rc
= my_ompd_init(version
, &table
);
815 if (rc
!= ompd_rc_ok
) {
816 printf("Failed, with return code = %d\n", rc
);
819 printf("Success.\n");
821 static ompd_callbacks_t invalid_table
= {
826 NULL
, /* _sym_addr, */
828 NULL
, NULL
, /* _read_string, */
829 NULL
, /* _endianess, */
830 NULL
, /* _endianess, */
831 NULL
, /* _thread_context */
834 // ompd_rc_bad_input: if invalid callbacks are provided
835 printf("Test: Invalid callbacks.\n");
836 rc
= my_ompd_init(version
, &invalid_table
);
837 if (rc
!= ompd_rc_bad_input
)
838 printf("Warning, with return code = %d\n", rc
);
840 printf("Success.\n");
842 // ompd_rc_unsupported: if the requested API version cannot be provided
843 printf("Test: Wrong API version.\n");
844 rc
= my_ompd_init(150847, &table
);
845 if (rc
!= ompd_rc_unsupported
)
846 printf("Failed, with return code = %d\n", rc
);
848 printf("Success.\n");
850 // Random checks with null and invalid args.
852 ompd_rc_stale_handle: is returned when the specified handle is no
854 ompd_rc_bad_input: is returned when the input parameters
855 (other than handle) are invalid;
856 ompd_rc_error: is returned when a fatal error occurred;
859 printf("Test: Expecting ompd_rc_bad_input for NULL table.\n");
860 rc
= my_ompd_init(version
, NULL
);
861 if (rc
!= ompd_rc_bad_input
)
862 printf("Failed, with return code = %d\n", rc
);
864 printf("Success.\n");
866 printf("Test: Expecting ompd_rc_error or ompd_rc_bad_input for NULL\n");
867 rc
= my_ompd_init(0, &table
);
868 if (rc
!= ompd_rc_unsupported
&& rc
!= ompd_rc_bad_input
)
869 printf("Failed, with return code = %d\n", rc
);
871 printf("Success.\n");
877 Test API: ompd_get_api_version
880 1. #include <stdio.h>
883 4. omp_set_num_threads(2);
884 5. #pragma omp parallel
886 7. printf("Parallel level 1, thread num = %d",
887 omp_get_thread_num());
895 ompdtestapi ompd_get_version
899 PyObject
*test_ompd_get_api_version(PyObject
*self
, PyObject
*noargs
) {
900 printf("Testing \"ompd_get_api_version\"...\n");
904 printf("Test: With Correct Arguments.\n");
905 ompd_rc_t rc
= ompd_get_api_version(&version
);
906 if (rc
!= ompd_rc_ok
) {
907 printf("Failed, with return code = %d\n", rc
);
910 printf("Success. API version is %ld\n", version
);
913 "Test: Expecting ompd_rc_error or ompd_rc_bad_input for NULL version\n");
914 rc
= ompd_get_api_version(NULL
);
915 if (rc
!= ompd_rc_error
&& rc
!= ompd_rc_bad_input
)
916 printf("Failed, with return code = %d\n", rc
);
918 printf("Success.\n");
924 Test API: ompd_get_version_string
927 1. #include <stdio.h>
930 4. omp_set_num_threads(2);
931 5. #pragma omp parallel
933 7. printf("Parallel level 1, thread num = %d",
934 omp_get_thread_num());
942 omptestapi ompd_get_version_string
946 PyObject
*test_ompd_get_version_string(PyObject
*self
, PyObject
*noargs
) {
947 printf("Testing \"ompd_get_version_string\"...\n");
951 printf("Test: With Correct Arguments.\n");
952 ompd_rc_t rc
= ompd_get_version_string(&string
);
953 if (rc
!= ompd_rc_ok
) {
954 printf("Failed, with return code = %d\n", rc
);
957 printf("Success. API version is %s\n", string
);
960 "Test: Expecting ompd_rc_error or ompd_rc_bad_input for NULL version\n");
961 rc
= ompd_get_version_string(NULL
);
962 if (rc
!= ompd_rc_error
&& rc
!= ompd_rc_bad_input
)
963 printf("Failed, with return code = %d\n", rc
);
965 printf("Success.\n");
971 Test API: ompd_finalize
974 1. #include <stdio.h>
977 4. omp_set_num_threads(2);
978 5. #pragma omp parallel
980 7. printf("Parallel level 1, thread num = %d",
981 omp_get_thread_num());
989 ompdtestapi ompd_finalize
994 ompdtestapi ompd_finalize
997 PyObject
*test_ompd_finalize(PyObject
*self
, PyObject
*noargs
) {
998 printf("Testing \"ompd_finalize\"...\n");
1000 printf("Test: With Correct Arguments.\n");
1001 ompd_rc_t rc
= ompd_finalize();
1002 if (rc
== ompd_rc_ok
)
1003 printf("Ret code: ompd_rc_ok, Success if ompd is initialized.\n");
1004 // ompd_rc_unsupported: if the OMPD library is not initialized.
1005 else if (rc
== ompd_rc_unsupported
)
1007 "Ret code: ompd_rc_unsupported, Success if ompd is NOT initialized.\n");
1009 printf("Failed: Return code is %d.\n", rc
);
1015 Test API: ompd_process_initialize
1018 1. #include <stdio.h>
1021 4. omp_set_num_threads(2);
1022 5. #pragma omp parallel
1024 7. printf("Parallel level 1, thread num = %d",
1025 omp_get_thread_num());
1034 PyObject
*test_ompd_process_initialize(PyObject
*self
, PyObject
*noargs
) {
1036 printf("Testing \"ompd_process_initialize\"....\n");
1038 ompd_address_space_handle_t
*addr_handle
;
1040 // ompd_address_space_context_t context = {42};
1042 printf("Test: with correct Args.\n");
1043 ompd_rc_t rc
= ompd_process_initialize(&context
, &addr_handle
);
1044 if (rc
!= ompd_rc_ok
) {
1045 printf("Failed, with return code = %d\n", rc
);
1048 printf("Success.\n");
1050 printf("Test: With Unsupported library.\n");
1051 printf("Warning: Have to test manually with 32 and 64 bit combination.\n");
1053 // ompd_address_space_context_t invalidcontext = {99};
1054 printf("Test: with wrong context value.\n");
1055 rc
= ompd_process_initialize(&invalidcontext
, &addr_handle
);
1056 if ((rc
!= ompd_rc_bad_input
) && (rc
!= ompd_rc_incompatible
) &&
1057 (rc
!= ompd_rc_stale_handle
))
1058 printf("Failed, with return code = %d\n", rc
);
1060 printf("Success.\n");
1062 // Random checks with null and invalid args.
1064 ompd_rc_stale_handle: is returned when the specified handle is no
1066 ompd_rc_bad_input: is returned when the input parameters
1067 (other than handle) are invalid;
1068 ompd_rc_error: is returned when a fatal error occurred;
1071 printf("Test: Expecting stale handle or bad_input for NULL addr_handle.\n");
1072 rc
= ompd_process_initialize(&context
, NULL
);
1073 if ((rc
!= ompd_rc_bad_input
) && (rc
!= ompd_rc_stale_handle
))
1074 printf("Failed, with return code = %d\n", rc
);
1076 printf("Success.\n");
1082 Test API: ompd_device_initialize
1085 1. #include <stdio.h>
1088 4. omp_set_num_threads(2);
1089 5. #pragma omp parallel
1091 7. printf("Parallel level 1, thread num = %d",
1092 omp_get_thread_num());
1101 PyObject
*test_ompd_device_initialize(PyObject
*self
, PyObject
*noargs
) {
1102 printf("Testing Not enabled for \"ompd_device_initialize\".\n");
1103 printf("Disabled.\n");
1109 Test API: ompd_rel_address_space_handle
1112 1. #include <stdio.h>
1115 4. omp_set_num_threads(2);
1116 5. #pragma omp parallel
1118 7. printf("Parallel level 1, thread num = %d",
1119 omp_get_thread_num());
1127 PyObject
*test_ompd_rel_address_space_handle(PyObject
*self
, PyObject
*noargs
) {
1128 printf("Testing Not enabled for \"ompd_rel_address_space_handle\".\n");
1129 printf("Disabled.\n");
1135 Test API: ompd_get_omp_version
1138 1. #include <stdio.h>
1141 4. omp_set_num_threads(2);
1142 5. #pragma omp parallel
1144 7. printf("Parallel level 1, thread num = %d",
1145 omp_get_thread_num());
1154 ompdtestapi ompd_get_omp_version
1156 PyObject
*test_ompd_get_omp_version(PyObject
*self
, PyObject
*args
) {
1157 printf("Testing \"ompd_get_omp_version\" ...\n");
1159 PyObject
*addrSpaceTup
= PyTuple_GetItem(args
, 0);
1160 ompd_address_space_handle_t
*addr_handle
=
1161 (ompd_address_space_handle_t
*)PyCapsule_GetPointer(addrSpaceTup
,
1164 ompd_word_t omp_version
;
1166 printf("Test: With Correct Arguments.\n");
1167 ompd_rc_t rc
= ompd_get_omp_version(addr_handle
, &omp_version
);
1168 if (rc
!= ompd_rc_ok
) {
1169 printf("Failed, with return code = %d\n", rc
);
1172 printf("Success. API version is %ld\n", omp_version
);
1174 // Random checks with null and invalid args.
1176 ompd_rc_stale_handle: is returned when the specified handle is no
1178 ompd_rc_bad_input: is returned when the input parameters
1179 (other than handle) are invalid;
1180 ompd_rc_error: is returned when a fatal error occurred;
1183 printf("Test: Expecting stale handle or bad_input for NULL addr_handle.\n");
1184 rc
= ompd_get_omp_version(NULL
, &omp_version
);
1185 if ((rc
!= ompd_rc_bad_input
) && (rc
!= ompd_rc_stale_handle
))
1186 printf("Failed, with return code = %d\n", rc
);
1188 printf("Success.\n");
1190 printf("Test: Expecting ompd_rc_error or bad_input for NULL omp_version.\n");
1191 rc
= ompd_get_omp_version(addr_handle
, NULL
);
1192 if (rc
!= ompd_rc_error
&& rc
!= ompd_rc_bad_input
)
1193 printf("Failed, with return code = %d\n", rc
);
1195 printf("Success.\n");
1201 Test API: ompd_get_omp_version_string
1204 1. #include <stdio.h>
1207 4. omp_set_num_threads(2);
1208 5. #pragma omp parallel
1210 7. printf("Parallel level 1, thread num = %d",
1211 omp_get_thread_num());
1219 ompdtestapi ompd_get_omp_version_string
1221 PyObject
*test_ompd_get_omp_version_string(PyObject
*self
, PyObject
*args
) {
1222 printf("Testing \"ompd_get_omp_version_string\" ...\n");
1224 PyObject
*addrSpaceTup
= PyTuple_GetItem(args
, 0);
1225 ompd_address_space_handle_t
*addr_handle
=
1226 (ompd_address_space_handle_t
*)PyCapsule_GetPointer(addrSpaceTup
,
1231 printf("Test: With Correct Arguments.\n");
1232 ompd_rc_t rc
= ompd_get_omp_version_string(addr_handle
, &string
);
1233 if (rc
!= ompd_rc_ok
) {
1234 printf("Failed, with return code = %d\n", rc
);
1237 printf("Success. API version is %s\n", string
);
1239 // Random checks with null and invalid args.
1241 ompd_rc_stale_handle: is returned when the specified handle is no
1243 ompd_rc_bad_input: is returned when the input parameters
1244 (other than handle) are invalid;
1245 ompd_rc_error: is returned when a fatal error occurred;
1248 printf("Test: Expecting stale handle or bad_input for NULL addr_handle.\n");
1249 rc
= ompd_get_omp_version_string(NULL
, &string
);
1250 if ((rc
!= ompd_rc_bad_input
) && (rc
!= ompd_rc_stale_handle
))
1251 printf("Failed, with return code = %d\n", rc
);
1253 printf("Success.\n");
1255 printf("Test: Expecting ompd_rc_error or bad_input for NULL omp_version.\n");
1256 rc
= ompd_get_omp_version_string(addr_handle
, NULL
);
1257 if (rc
!= ompd_rc_error
&& rc
!= ompd_rc_bad_input
)
1258 printf("Failed, with return code = %d\n", rc
);
1260 printf("Success.\n");
1266 Test API: ompd_get_curr_task_handle
1269 1 #include <stdio.h>
1271 3 int get_fib_num (int num)
1277 9 #pragma omp task shared(t1)
1278 10 t1 = get_fib_num(num-1);
1279 11 #pragma omp task shared(t2)
1280 12 t2 = get_fib_num(num-2);
1281 13 #pragma omp taskwait
1288 20 omp_set_num_threads(2);
1289 21 #pragma omp parallel
1291 23 ret = get_fib_num(10);
1293 25 printf ("Fib of 10 is %d", ret);
1301 ompdtestapi ompd_get_curr_task_handle
1304 PyObject
*test_ompd_get_curr_task_handle(PyObject
*self
, PyObject
*args
) {
1305 printf("Testing \"ompd_get_curr_task_handle\"...\n");
1307 PyObject
*threadHandlePy
= PyTuple_GetItem(args
, 0);
1308 ompd_thread_handle_t
*thread_handle
=
1309 (ompd_thread_handle_t
*)(PyCapsule_GetPointer(threadHandlePy
,
1312 ompd_task_handle_t
*task_handle
;
1314 printf("Test: With Correct Arguments.\n");
1315 ompd_rc_t rc
= ompd_get_curr_task_handle(thread_handle
, &task_handle
);
1316 if (rc
== ompd_rc_unavailable
) {
1317 // ompd_rc_unavailable if the thread is not currently executing a task
1320 "Success. Return code is ompd_rc_unavailable, Not executing a task.\n");
1321 printf("No more testing is possible.\n");
1323 } else if (rc
== ompd_rc_stale_handle
) {
1324 printf("Return code is stale_handle, may be in non parallel region.\n");
1325 printf("No more testing is possible.\n");
1327 } else if (rc
!= ompd_rc_ok
)
1328 printf("Failed. with return code = %d\n", rc
);
1330 printf("Success.\n");
1332 // Random checks with null and invalid args.
1334 ompd_rc_stale_handle: is returned when the specified handle is no
1336 ompd_rc_bad_input: is returned when the input parameters
1337 (other than handle) are invalid;
1338 ompd_rc_error: is returned when a fatal error occurred;
1341 printf("Test: Expecting ompd_rc_bad_input for NULL parallel_handle.\n");
1342 rc
= ompd_get_curr_task_handle(thread_handle
, NULL
);
1343 if (rc
!= ompd_rc_bad_input
)
1344 printf("Failed. with return code = %d\n", rc
);
1346 printf("Success.\n");
1348 printf("Test: Expecting ompd_rc_error or stale_handle for NULL "
1349 "thread_handle.\n");
1350 rc
= ompd_get_curr_task_handle(NULL
, &task_handle
);
1351 if (rc
!= ompd_rc_error
&& rc
!= ompd_rc_stale_handle
)
1352 printf("Failed. with return code = %d\n", rc
);
1354 printf("Success.\n");
1360 Test API: ompd_get_task_parallel_handle
1363 1 #include <stdio.h>
1365 3 int get_fib_num (int num)
1371 9 #pragma omp task shared(t1)
1372 10 t1 = get_fib_num(num-1);
1373 11 #pragma omp task shared(t2)
1374 12 t2 = get_fib_num(num-2);
1375 13 #pragma omp taskwait
1382 20 omp_set_num_threads(2);
1383 21 #pragma omp parallel
1385 23 ret = get_fib_num(10);
1387 25 printf ("Fib of 10 is %d", ret);
1395 ompdtestapi ompd_get_task_parallel_handle
1397 PyObject
*test_ompd_get_task_parallel_handle(PyObject
*self
, PyObject
*args
) {
1399 printf("Testing \"ompd_get_task_parallel_handle\"...\n");
1401 PyObject
*taskHandlePy
= PyTuple_GetItem(args
, 0);
1402 ompd_task_handle_t
*task_handle
=
1403 PyCapsule_GetPointer(taskHandlePy
, "TaskHandle");
1405 ompd_parallel_handle_t
*task_parallel_handle
;
1407 printf("Test: With Correct Arguments.\n");
1409 ompd_get_task_parallel_handle(task_handle
, &task_parallel_handle
);
1410 if (rc
!= ompd_rc_ok
) {
1411 printf("Failed. with return code = %d\n", rc
);
1414 printf("Success.\n");
1416 // Random checks with null and invalid args.
1418 ompd_rc_stale_handle: is returned when the specified handle is no
1420 ompd_rc_bad_input: is returned when the input parameters
1421 (other than handle) are invalid;
1422 ompd_rc_error: is returned when a fatal error occurred;
1425 printf("Test: Expecting ompd_rc_bad_input for NULL task_parallel_handle.\n");
1426 rc
= ompd_get_task_parallel_handle(task_handle
, NULL
);
1427 if (rc
!= ompd_rc_bad_input
)
1428 printf("Failed. with return code = %d\n", rc
);
1430 printf("Success.\n");
1433 "Test: Expecting ompd_rc_error or stale_handle for NULL task_handle.\n");
1434 rc
= ompd_get_task_parallel_handle(NULL
, &task_parallel_handle
);
1435 if (rc
!= ompd_rc_error
&& rc
!= ompd_rc_stale_handle
)
1436 printf("Failed. with return code = %d\n", rc
);
1438 printf("Success.\n");
1444 Test API: ompd_get_generating_task_handle
1447 1 #include <stdio.h>
1449 3 int get_fib_num (int num)
1455 9 #pragma omp task shared(t1)
1456 10 t1 = get_fib_num(num-1);
1457 11 #pragma omp task shared(t2)
1458 12 t2 = get_fib_num(num-2);
1459 13 #pragma omp taskwait
1466 20 omp_set_num_threads(2);
1467 21 #pragma omp parallel
1469 23 ret = get_fib_num(10);
1471 25 printf ("Fib of 10 is %d", ret);
1479 c // may or may not be needed
1480 ompdtestapi ompd_get_generating_task_handle
1482 PyObject
*test_ompd_get_generating_task_handle(PyObject
*self
, PyObject
*args
) {
1483 printf("Testing \"ompd_get_generating_task_handle\"...\n");
1485 PyObject
*taskHandlePy
= PyTuple_GetItem(args
, 0);
1486 ompd_task_handle_t
*task_handle
=
1487 (ompd_task_handle_t
*)(PyCapsule_GetPointer(taskHandlePy
, "TaskHandle"));
1488 ompd_task_handle_t
*generating_task_handle
;
1490 printf("Test: With Correct Arguments.\n");
1492 ompd_get_generating_task_handle(task_handle
, &generating_task_handle
);
1493 if (rc
== ompd_rc_unavailable
) {
1494 // ompd_rc_unavailable if no generating task handle exists.
1495 printf("Success. Return code is ompd_rc_unavailable\n");
1496 printf("No more testing is possible.\n");
1498 } else if (rc
!= ompd_rc_ok
) {
1499 printf("Failed. with return code = %d\n", rc
);
1502 printf("Success.\n");
1504 // Random checks with null and invalid args.
1506 ompd_rc_stale_handle: is returned when the specified handle is no
1508 ompd_rc_bad_input: is returned when the input parameters
1509 (other than handle) are invalid;
1510 ompd_rc_error: is returned when a fatal error occurred;
1514 "Test: Expecting ompd_rc_bad_input for NULL generating_task_handle.\n");
1515 rc
= ompd_get_generating_task_handle(task_handle
, NULL
);
1516 if (rc
!= ompd_rc_bad_input
)
1517 printf("Failed. with return code = %d\n", rc
);
1519 printf("Success.\n");
1522 "Test: Expecting ompd_rc_error or stale_handle for NULL task_handle.\n");
1523 rc
= ompd_get_generating_task_handle(NULL
, &generating_task_handle
);
1524 if (rc
!= ompd_rc_error
&& rc
!= ompd_rc_stale_handle
)
1525 printf("Failed. with return code = %d\n", rc
);
1527 printf("Success.\n");
1533 Test API: ompd_get_scheduling_task_handle
1536 1 #include <stdio.h>
1538 3 int get_fib_num (int num)
1544 9 #pragma omp task shared(t1)
1545 10 t1 = get_fib_num(num-1);
1546 11 #pragma omp task shared(t2)
1547 12 t2 = get_fib_num(num-2);
1548 13 #pragma omp taskwait
1555 20 omp_set_num_threads(2);
1556 21 #pragma omp parallel
1558 23 ret = get_fib_num(10);
1560 25 printf ("Fib of 10 is %d", ret);
1568 ompdtestapi ompd_get_scheduling_task_handle
1570 PyObject
*test_ompd_get_scheduling_task_handle(PyObject
*self
, PyObject
*args
) {
1571 printf("Testing \"ompd_get_scheduling_task_handle\"...\n");
1573 PyObject
*taskHandlePy
= PyTuple_GetItem(args
, 0);
1574 ompd_task_handle_t
*task_handle
=
1575 (ompd_task_handle_t
*)(PyCapsule_GetPointer(taskHandlePy
, "TaskHandle"));
1576 ompd_task_handle_t
*scheduling_task_handle
;
1578 printf("Test: With Correct Arguments.\n");
1580 ompd_get_scheduling_task_handle(task_handle
, &scheduling_task_handle
);
1581 if (rc
== ompd_rc_unavailable
) {
1582 // ompd_rc_unavailable if no generating task handle exists.
1584 "Success. Return code is ompd_rc_unavailable, No scheduling task.\n");
1585 printf("No more testing is possible.\n");
1587 } else if (rc
!= ompd_rc_ok
) {
1588 printf("Failed. with return code = %d\n", rc
);
1591 printf("Success.\n");
1593 // Random checks with null and invalid args.
1595 ompd_rc_stale_handle: is returned when the specified handle is no
1597 ompd_rc_bad_input: is returned when the input parameters
1598 (other than handle) are invalid;
1599 ompd_rc_error: is returned when a fatal error occurred;
1603 "Test: Expecting ompd_rc_bad_input for NULL scheduling_task_handle.\n");
1604 rc
= ompd_get_scheduling_task_handle(task_handle
, NULL
);
1605 if (rc
!= ompd_rc_bad_input
)
1606 printf("Failed. with return code = %d\n", rc
);
1608 printf("Success.\n");
1611 "Test: Expecting ompd_rc_error or stale_handle for NULL task_handle.\n");
1612 rc
= ompd_get_scheduling_task_handle(NULL
, &scheduling_task_handle
);
1613 if (rc
!= ompd_rc_error
&& rc
!= ompd_rc_stale_handle
)
1614 printf("Failed. with return code = %d\n", rc
);
1616 printf("Success.\n");
1622 Test API: ompd_get_task_in_parallel
1626 1. #include <stdio.h>
1629 4. omp_set_num_threads(4);
1630 5. #pragma omp parallel
1632 7. printf("Parallel level 1, thread num = %d",
1633 omp_get_thread_num());
1642 ompdtestapi ompd_get_task_in_parallel
1644 PyObject
*test_ompd_get_task_in_parallel(PyObject
*self
, PyObject
*args
) {
1645 printf("Testing \"ompd_get_task_in_parallel\"...\n");
1647 PyObject
*parallelHandlePy
= PyTuple_GetItem(args
, 0);
1648 ompd_parallel_handle_t
*parallel_handle
=
1649 (ompd_parallel_handle_t
*)(PyCapsule_GetPointer(parallelHandlePy
,
1651 ompd_task_handle_t
*task_handle
;
1653 printf("Test: With Correct Arguments.\n");
1654 ompd_rc_t rc
= ompd_get_task_in_parallel(
1655 parallel_handle
, 1 /* lesser than team-size-var*/, &task_handle
);
1656 if (rc
!= ompd_rc_ok
) {
1657 printf("Failed. with return code = %d\n", rc
);
1660 printf("Success.\n");
1662 // ompd_rc_bad_input if the thread_num argument is greater than or equal to
1663 // the team-size-var ICV or negative
1664 printf("Test: Invalid thread num (199).\n");
1665 rc
= ompd_get_task_in_parallel(parallel_handle
, 199, &task_handle
);
1666 if (rc
!= ompd_rc_bad_input
)
1667 printf("Failed. with return code = %d\n", rc
);
1669 printf("Success.\n");
1671 printf("Test: Invalid thread num (-5).\n");
1672 rc
= ompd_get_task_in_parallel(parallel_handle
, -5, &task_handle
);
1673 if (rc
!= ompd_rc_bad_input
)
1674 printf("Failed. with return code = %d\n", rc
);
1676 printf("Success.\n");
1678 // Random checks with null and invalid args.
1680 ompd_rc_stale_handle: is returned when the specified handle is no
1682 ompd_rc_bad_input: is returned when the input parameters
1683 (other than handle) are invalid;
1684 ompd_rc_error: is returned when a fatal error occurred;
1687 printf("Test: Expecting ompd_rc_bad_input for NULL task_handle.\n");
1688 rc
= ompd_get_task_in_parallel(parallel_handle
, 1, NULL
);
1689 if (rc
!= ompd_rc_bad_input
)
1690 printf("Failed. with return code = %d\n", rc
);
1692 printf("Success.\n");
1694 printf("Test: Expecting ompd_rc_error or stale_handle for NULL "
1695 "parallel_handle.\n");
1696 rc
= ompd_get_task_in_parallel(NULL
, 1, &task_handle
);
1697 if (rc
!= ompd_rc_error
&& rc
!= ompd_rc_stale_handle
)
1698 printf("Failed. with return code = %d\n", rc
);
1700 printf("Success.\n");
1706 Test API: ompd_rel_task_handle
1709 1 #include <stdio.h>
1711 3 int get_fib_num (int num)
1717 9 #pragma omp task shared(t1)
1718 10 t1 = get_fib_num(num-1);
1719 11 #pragma omp task shared(t2)
1720 12 t2 = get_fib_num(num-2);
1721 13 #pragma omp taskwait
1728 20 omp_set_num_threads(2);
1729 21 #pragma omp parallel
1731 23 ret = get_fib_num(10);
1733 25 printf ("Fib of 10 is %d", ret);
1741 ompdtestapi ompd_rel_task_handle
1743 PyObject
*test_ompd_rel_task_handle(PyObject
*self
, PyObject
*noargs
) {
1744 printf("Testing Not enabled for \"ompd_rel_task_handle\".\n");
1745 printf("Disabled.\n");
1751 Test API: ompd_task_handle_compare
1754 1 #include <stdio.h>
1756 3 int get_fib_num (int num)
1762 9 #pragma omp task shared(t1)
1763 10 t1 = get_fib_num(num-1);
1764 11 #pragma omp task shared(t2)
1765 12 t2 = get_fib_num(num-2);
1766 13 #pragma omp taskwait
1773 20 omp_set_num_threads(2);
1774 21 #pragma omp parallel
1776 23 ret = get_fib_num(10);
1778 25 printf ("Fib of 10 is %d", ret);
1787 ompdtestapi ompd_task_handle_compare
1789 PyObject
*test_ompd_task_handle_compare(PyObject
*self
, PyObject
*args
) {
1790 printf("Testing \"ompd_task_handle_compare\"...\n");
1792 PyObject
*taskHandlePy1
= PyTuple_GetItem(args
, 0);
1793 ompd_task_handle_t
*task_handle1
=
1794 (ompd_task_handle_t
*)(PyCapsule_GetPointer(taskHandlePy1
, "TaskHandle"));
1795 PyObject
*taskHandlePy2
= PyTuple_GetItem(args
, 1);
1796 ompd_task_handle_t
*task_handle2
=
1797 (ompd_task_handle_t
*)(PyCapsule_GetPointer(taskHandlePy2
, "TaskHandle"));
1801 printf("Test: With Correct Arguments.\n");
1803 ompd_task_handle_compare(task_handle1
, task_handle2
, &cmp_value
);
1804 if (rc
!= ompd_rc_ok
) {
1805 printf("Failed. with return code = %d\n", rc
);
1808 printf("Success.\n");
1810 if (cmp_value
== 0) {
1811 printf("Task Handles are Same.\n");
1813 // a value less than, equal to, or greater than 0 indicates that the task
1814 // that corresponds to task_handle_1 is, respectively, less than, equal to,
1815 // or greater than the task that corresponds to task_handle_2.
1816 if (cmp_value
<= 0) {
1817 printf("Task handle 1 is lesser than handle 2, cmp_val = %d\n",
1819 printf("Test: Changing the order.\n");
1820 rc
= ompd_task_handle_compare(task_handle2
, task_handle1
, &cmp_value
);
1821 if (rc
!= ompd_rc_ok
) {
1822 printf("Failed. with return code = %d\n", rc
);
1826 printf("Success now cmp_value is greater, %d.\n", cmp_value
);
1828 printf("Failed.\n");
1830 printf("Task 1 is greater than handle 2.\n");
1831 printf("Test: Changing the order.\n");
1832 rc
= ompd_task_handle_compare(task_handle2
, task_handle1
, &cmp_value
);
1833 if (rc
!= ompd_rc_ok
) {
1834 printf("Failed. with return code = %d\n", rc
);
1838 printf("Success now cmp_value is lesser, %d.\n", cmp_value
);
1840 printf("Failed.\n");
1843 // Random checks with null and invalid args.
1845 ompd_rc_stale_handle: is returned when the specified handle is no
1847 ompd_rc_bad_input: is returned when the input parameters
1848 (other than handle) are invalid;
1849 ompd_rc_error: is returned when a fatal error occurred;
1852 printf("Test: Expecting ompd_rc_bad_input for NULL cmp_value.\n");
1853 rc
= ompd_task_handle_compare(task_handle2
, task_handle1
, NULL
);
1854 if (rc
!= ompd_rc_bad_input
)
1855 printf("Failed. with return code = %d\n", rc
);
1857 printf("Success.\n");
1859 printf("Test: Expecting ompd_rc_error or stale_handle for NULL "
1861 rc
= ompd_task_handle_compare(NULL
, task_handle1
, &cmp_value
);
1862 if (rc
!= ompd_rc_error
&& rc
!= ompd_rc_stale_handle
)
1863 printf("Failed. with return code = %d\n", rc
);
1865 printf("Success.\n");
1872 Test API: ompd_get_task_function
1875 1 #include <stdio.h>
1877 3 int get_fib_num (int num)
1883 9 #pragma omp task shared(t1)
1884 10 t1 = get_fib_num(num-1);
1885 11 #pragma omp task shared(t2)
1886 12 t2 = get_fib_num(num-2);
1887 13 #pragma omp taskwait
1894 20 omp_set_num_threads(2);
1895 21 #pragma omp parallel
1897 23 ret = get_fib_num(10);
1899 25 printf ("Fib of 10 is %d", ret);
1907 ompdtestapi ompd_get_task_function
1909 PyObject
*test_ompd_get_task_function(PyObject
*self
, PyObject
*args
) {
1910 printf("Testing \"ompd_get_task_function\"...\n");
1912 PyObject
*taskHandlePy
= PyTuple_GetItem(args
, 0);
1913 ompd_task_handle_t
*task_handle
=
1914 (ompd_task_handle_t
*)(PyCapsule_GetPointer(taskHandlePy
, "TaskHandle"));
1916 ompd_address_t entry_point
;
1918 printf("Test: With Correct Arguments.\n");
1919 ompd_rc_t rc
= ompd_get_task_function(task_handle
, &entry_point
);
1920 if (rc
!= ompd_rc_ok
) {
1921 printf("Failed. with return code = %d\n", rc
);
1924 printf("Success. Entry point is %lx.\n", entry_point
.address
);
1926 // Random checks with null and invalid args.
1928 ompd_rc_stale_handle: is returned when the specified handle is no
1930 ompd_rc_bad_input: is returned when the input parameters
1931 (other than handle) are invalid;
1932 ompd_rc_error: is returned when a fatal error occurred;
1935 printf("Test: Expecting ompd_rc_bad_input for NULL entry_point.\n");
1936 rc
= ompd_get_task_function(task_handle
, NULL
);
1937 if (rc
!= ompd_rc_bad_input
)
1938 printf("Failed. with return code = %d\n", rc
);
1940 printf("Success.\n");
1943 "Test: Expecting ompd_rc_error or stale_handle for NULL task_handle.\n");
1944 rc
= ompd_get_task_function(NULL
, &entry_point
);
1945 if (rc
!= ompd_rc_error
&& rc
!= ompd_rc_stale_handle
)
1946 printf("Failed. with return code = %d\n", rc
);
1948 printf("Success.\n");
1954 Test API: ompd_get_task_frame
1957 1 #include <stdio.h>
1959 3 int get_fib_num (int num)
1965 9 #pragma omp task shared(t1)
1966 10 t1 = get_fib_num(num-1);
1967 11 #pragma omp task shared(t2)
1968 12 t2 = get_fib_num(num-2);
1969 13 #pragma omp taskwait
1976 20 omp_set_num_threads(2);
1977 21 #pragma omp parallel
1979 23 ret = get_fib_num(10);
1981 25 printf ("Fib of 10 is %d", ret);
1989 ompdtestapi ompd_get_task_frame
1991 PyObject
*test_ompd_get_task_frame(PyObject
*self
, PyObject
*args
) {
1992 printf("Testing \"ompd_get_task_frame\"...\n");
1994 PyObject
*taskHandlePy
= PyTuple_GetItem(args
, 0);
1995 ompd_task_handle_t
*task_handle
=
1996 (ompd_task_handle_t
*)(PyCapsule_GetPointer(taskHandlePy
, "TaskHandle"));
1998 ompd_frame_info_t exit_frame
;
1999 ompd_frame_info_t enter_frame
;
2001 printf("Test: With Correct Arguments.\n");
2002 ompd_rc_t rc
= ompd_get_task_frame(task_handle
, &exit_frame
, &enter_frame
);
2003 if (rc
!= ompd_rc_ok
) {
2004 printf("Failed. with return code = %d\n", rc
);
2007 printf("Success.\n");
2009 // Random checks with null and invalid args.
2011 ompd_rc_stale_handle: is returned when the specified handle is no
2013 ompd_rc_bad_input: is returned when the input parameters
2014 (other than handle) are invalid;
2015 ompd_rc_error: is returned when a fatal error occurred;
2018 printf("Test: Expecting ompd_rc_bad_input for NULL exit and enter frame.\n");
2019 rc
= ompd_get_task_frame(task_handle
, NULL
, NULL
);
2020 if (rc
!= ompd_rc_bad_input
)
2021 printf("Failed. with return code = %d\n", rc
);
2023 printf("Success.\n");
2026 "Test: Expecting ompd_rc_error or stale handle for NULL task_handle.\n");
2027 rc
= ompd_get_task_frame(NULL
, &exit_frame
, &enter_frame
);
2028 if (rc
!= ompd_rc_error
&& rc
!= ompd_rc_stale_handle
)
2029 printf("Failed. with return code = %d\n", rc
);
2031 printf("Success.\n");
2037 Test API: ompd_get_state
2041 1. #include <stdio.h>
2044 4. omp_set_num_threads(4);
2045 5. #pragma omp parallel
2047 7. printf("Parallel level 1, thread num = %d",
2048 omp_get_thread_num());
2057 ompdtestapi ompd_get_state
2059 PyObject
*test_ompd_get_state(PyObject
*self
, PyObject
*args
) {
2060 printf("Testing \"ompd_get_state\"...\n");
2062 PyObject
*threadHandlePy
= PyTuple_GetItem(args
, 0);
2063 ompd_thread_handle_t
*thread_handle
=
2064 (ompd_thread_handle_t
*)(PyCapsule_GetPointer(threadHandlePy
,
2068 ompt_wait_id_t wait_id
;
2070 printf("Test: With Correct Arguments.\n");
2071 ompd_rc_t rc
= ompd_get_state(thread_handle
, &state
, &wait_id
);
2072 if (rc
!= ompd_rc_ok
) {
2073 printf("Failed. with return code = %d\n", rc
);
2076 printf("Success.\n");
2078 // Random checks with null and invalid args.
2080 ompd_rc_stale_handle: is returned when the specified handle is no
2082 ompd_rc_bad_input: is returned when the input parameters
2083 (other than handle) are invalid;
2084 ompd_rc_error: is returned when a fatal error occurred;
2087 printf("Test: Expecting ompd_rc_error or stale handle for NULL "
2088 "thread_handle.\n");
2089 rc
= ompd_get_state(NULL
, &state
, &wait_id
);
2090 if (rc
!= ompd_rc_error
&& rc
!= ompd_rc_stale_handle
)
2091 printf("Failed. with return code = %d\n", rc
);
2093 printf("Success.\n");
2099 Test API: ompd_get_display_control_vars
2102 1 #include <stdio.h>
2104 3 int get_fib_num (int num)
2110 9 #pragma omp task shared(t1)
2111 10 t1 = get_fib_num(num-1);
2112 11 #pragma omp task shared(t2)
2113 12 t2 = get_fib_num(num-2);
2114 13 #pragma omp taskwait
2121 20 omp_set_num_threads(2);
2122 21 #pragma omp parallel
2124 23 ret = get_fib_num(10);
2126 25 printf ("Fib of 10 is %d", ret);
2134 ompdtestapi ompd_get_display_control_vars
2136 PyObject
*test_ompd_get_display_control_vars(PyObject
*self
, PyObject
*args
) {
2137 printf("Testing \"ompd_get_display_control_vars\" ...\n");
2139 PyObject
*addrSpaceTup
= PyTuple_GetItem(args
, 0);
2140 ompd_address_space_handle_t
*addr_handle
=
2141 (ompd_address_space_handle_t
*)PyCapsule_GetPointer(addrSpaceTup
,
2144 const char *const *control_vars
;
2146 printf("Test: With Correct Arguments.\n");
2147 ompd_rc_t rc
= ompd_get_display_control_vars(addr_handle
, &control_vars
);
2148 if (rc
!= ompd_rc_ok
) {
2149 printf("Failed. with return code = %d\n", rc
);
2152 printf("Success.\n");
2154 // Random checks with null and invalid args.
2156 ompd_rc_stale_handle: is returned when the specified handle is no
2158 ompd_rc_bad_input: is returned when the input parameters
2159 (other than handle) are invalid;
2160 ompd_rc_error: is returned when a fatal error occurred;
2163 printf("Test: Expecting stale handle or bad_input for NULL addr_handle.\n");
2164 rc
= ompd_get_display_control_vars(NULL
, &control_vars
);
2165 if ((rc
!= ompd_rc_bad_input
) && (rc
!= ompd_rc_stale_handle
))
2166 printf("Failed. with return code = %d\n", rc
);
2168 printf("Success.\n");
2170 printf("Test: Expecting ompd_rc_error or bad_input for NULL control_vars.\n");
2171 rc
= ompd_get_display_control_vars(addr_handle
, NULL
);
2172 if (rc
!= ompd_rc_error
&& rc
!= ompd_rc_bad_input
)
2173 printf("Failed. with return code = %d\n", rc
);
2175 printf("Success.\n");
2181 Test API: ompd_rel_display_control_vars
2184 1 #include <stdio.h>
2186 3 int get_fib_num (int num)
2192 9 #pragma omp task shared(t1)
2193 10 t1 = get_fib_num(num-1);
2194 11 #pragma omp task shared(t2)
2195 12 t2 = get_fib_num(num-2);
2196 13 #pragma omp taskwait
2203 20 omp_set_num_threads(2);
2204 21 #pragma omp parallel
2206 23 ret = get_fib_num(10);
2208 25 printf ("Fib of 10 is %d", ret);
2216 ompdtestapi ompd_rel_display_control_vars
2218 PyObject
*test_ompd_rel_display_control_vars(PyObject
*self
, PyObject
*noargs
) {
2219 printf("Testing Not enabled for \"ompd_rel_display_control_vars\".\n");
2220 printf("Disabled.\n");
2226 Test API: ompd_enumerate_icvs
2230 1. #include <stdio.h>
2233 4. omp_set_num_threads(2);
2234 5. #pragma omp parallel
2236 7. printf("Parallel level 1, thread num = %d",
2237 omp_get_thread_num());
2246 ompdtestapi ompd_enumerate_icvs
2249 PyObject
*test_ompd_enumerate_icvs(PyObject
*self
, PyObject
*args
) {
2250 printf("Testing \"ompd_enumerate_icvs\"...\n");
2252 PyObject
*addrSpaceTup
= PyTuple_GetItem(args
, 0);
2253 ompd_address_space_handle_t
*addr_handle
=
2254 (ompd_address_space_handle_t
*)PyCapsule_GetPointer(addrSpaceTup
,
2257 ompd_icv_id_t current
= 0; // To begin enumerating the ICVs, a tool should
2258 // pass ompd_icv_undefined as the value of current
2259 ompd_icv_id_t next_id
;
2260 const char *next_icv_name
;
2261 ompd_scope_t next_scope
;
2264 printf("Test: With Correct Arguments.\n");
2265 ompd_rc_t rc
= ompd_enumerate_icvs(addr_handle
, current
, &next_id
,
2266 &next_icv_name
, &next_scope
, &more
);
2267 if (rc
!= ompd_rc_ok
) {
2268 printf("Failed. with return code = %d\n", rc
);
2271 printf("Success.\n");
2273 // ompd_rc_bad_input if an unknown value is provided in current
2274 printf("Test: Unknown current value.\n");
2275 rc
= ompd_enumerate_icvs(
2277 99 /*unknown current value: greater than enum "ompd_icvompd_icv" */,
2278 &next_id
, &next_icv_name
, &next_scope
, &more
);
2279 if (rc
!= ompd_rc_bad_input
)
2280 printf("Failed. with return code = %d\n", rc
);
2282 printf("Success.\n");
2284 // Random checks with null and invalid args.
2286 ompd_rc_stale_handle: is returned when the specified handle is no
2288 ompd_rc_bad_input: is returned when the input parameters
2289 (other than handle) are invalid;
2290 ompd_rc_error: is returned when a fatal error occurred;
2294 "Test: Expecting ompd_rc_bad_input for NULL next_id and next_icv_name\n");
2296 ompd_enumerate_icvs(addr_handle
, current
, NULL
, NULL
, &next_scope
, &more
);
2297 if (rc
!= ompd_rc_bad_input
)
2298 printf("Failed. with return code = %d\n", rc
);
2300 printf("Success.\n");
2303 "Test: Expecting ompd_rc_error or stale_handle for NULL addr_handle.\n");
2304 rc
= ompd_enumerate_icvs(NULL
, current
, &next_id
, &next_icv_name
, &next_scope
,
2306 if (rc
!= ompd_rc_error
&& rc
!= ompd_rc_stale_handle
)
2307 printf("Failed. with return code = %d\n", rc
);
2309 printf("Success.\n");
2315 Test API: ompd_get_icv_from_scope
2318 1 #include <stdio.h>
2320 3 int get_fib_num (int num)
2326 9 #pragma omp task shared(t1)
2327 10 t1 = get_fib_num(num-1);
2328 11 #pragma omp task shared(t2)
2329 12 t2 = get_fib_num(num-2);
2330 13 #pragma omp taskwait
2337 20 omp_set_num_threads(2);
2338 21 #pragma omp parallel
2340 23 ret = get_fib_num(10);
2342 25 printf ("Fib of 10 is %d", ret);
2350 ompdtestapi ompd_get_icv_from_scope
2352 PyObject
*test_ompd_get_icv_from_scope_with_addr_handle(PyObject
*self
,
2354 printf("Testing \"ompd_get_icv_from_scope with addr_handle\"...\n");
2356 PyObject
*addrSpaceTup
= PyTuple_GetItem(args
, 0);
2357 ompd_address_space_handle_t
*addr_handle
=
2358 (ompd_address_space_handle_t
*)PyCapsule_GetPointer(addrSpaceTup
,
2361 ompd_word_t icv_value
;
2363 printf("Test: With Correct Arguments.\n");
2364 // cannot import enum ompd_icv from omp-icv.cpp, hardcoding as of now, if enum
2365 // changes it also requires modification
2366 ompd_rc_t rc
= ompd_get_icv_from_scope(
2367 addr_handle
, ompd_scope_address_space
,
2368 19 /* ompd_icv_num_procs_var: check enum ompd_icv in omp-icv.cpp */,
2370 if (rc
!= ompd_rc_ok
) {
2371 printf("Failed. with return code = %d\n", rc
);
2374 printf("Success.\n");
2376 // ompd_rc_bad_input if an unknown value is provided in icv_id.
2377 printf("Test: bad_input for unknown icv_id.\n");
2378 rc
= ompd_get_icv_from_scope(addr_handle
, ompd_scope_address_space
,
2379 99 /*wrong value*/, &icv_value
);
2380 if (rc
!= ompd_rc_bad_input
)
2381 printf("Failed. with return code = %d\n", rc
);
2383 printf("Success.\n");
2385 // ompd_rc_incompatible if the ICV cannot be represented as an integer;
2386 printf("Test: rc_incompatible for ICV that cant be represented as an "
2388 rc
= ompd_get_icv_from_scope(addr_handle
, ompd_scope_address_space
,
2389 12 /*ompd_icv_tool_libraries_var*/, &icv_value
);
2390 if (rc
!= ompd_rc_incompatible
)
2391 printf("Failed. with return code = %d\n", rc
);
2393 printf("Success.\n");
2395 // Random checks with null and invalid args.
2397 ompd_rc_stale_handle: is returned when the specified handle is no
2399 ompd_rc_bad_input: is returned when the input parameters
2400 (other than handle) are invalid;
2401 ompd_rc_error: is returned when a fatal error occurred;
2404 printf("Test: Expecting ompd_rc_bad_input for NULL icv_value.\n");
2405 rc
= ompd_get_icv_from_scope(addr_handle
, ompd_scope_address_space
,
2406 19 /*ompd_icv_num_procs_var*/, NULL
);
2407 if (rc
!= ompd_rc_bad_input
)
2408 printf("Failed. with return code = %d\n", rc
);
2410 printf("Success.\n");
2412 printf("Test: Expecting ompd_rc_error for NULL handle.\n");
2413 rc
= ompd_get_icv_from_scope(NULL
, ompd_scope_address_space
,
2414 19 /*ompd_icv_num_procs_var*/, &icv_value
);
2415 if (rc
!= ompd_rc_error
&& rc
!= ompd_rc_stale_handle
)
2416 printf("Failed. with return code = %d\n", rc
);
2418 printf("Success.\n");
2423 PyObject
*test_ompd_get_icv_from_scope_with_thread_handle(PyObject
*self
,
2425 printf("Testing \"ompd_get_icv_from_scope with thread_handle\"...\n");
2427 PyObject
*threadHandlePy
= PyTuple_GetItem(args
, 0);
2428 ompd_thread_handle_t
*thread_handle
=
2429 (ompd_thread_handle_t
*)(PyCapsule_GetPointer(threadHandlePy
,
2432 ompd_word_t icv_value
;
2434 printf("Test: With Correct Arguments.\n");
2435 ompd_rc_t rc
= ompd_get_icv_from_scope(
2436 thread_handle
, ompd_scope_thread
,
2437 22 /* ompd_icv_thread_num_var check enum ompd_icv in omp-icv.cpp */,
2439 if (rc
!= ompd_rc_ok
) {
2440 printf("Failed. with return code = %d\n", rc
);
2443 printf("Success.\n");
2445 printf("Test: with nthreads_var for ompd_rc_incomplete.\n");
2446 rc
= ompd_get_icv_from_scope(thread_handle
, ompd_scope_thread
,
2447 7 /*ompd_icv_nthreads_var*/, &icv_value
);
2448 if (rc
!= ompd_rc_incomplete
) {
2449 printf("Failed. with return code = %d\n", rc
);
2452 printf("Success.\n");
2457 PyObject
*test_ompd_get_icv_from_scope_with_parallel_handle(PyObject
*self
,
2459 printf("Testing \"ompd_get_icv_from_scope with parallel_handle\"...\n");
2461 PyObject
*parallelHandlePy
= PyTuple_GetItem(args
, 0);
2462 ompd_parallel_handle_t
*parallel_handle
=
2463 (ompd_parallel_handle_t
*)(PyCapsule_GetPointer(parallelHandlePy
,
2466 ompd_word_t icv_value
;
2468 printf("Test: With Correct Arguments.\n");
2469 ompd_rc_t rc
= ompd_get_icv_from_scope(
2470 parallel_handle
, ompd_scope_parallel
,
2471 15 /*ompd_icv_active_levels_var:check enum ompd_icv in omp-icv.cpp */,
2473 if (rc
!= ompd_rc_ok
) {
2474 printf("Failed. with return code = %d\n", rc
);
2477 printf("Success.\n");
2482 PyObject
*test_ompd_get_icv_from_scope_with_task_handle(PyObject
*self
,
2484 printf("Testing \"ompd_get_icv_from_scope with task_handle\"...\n");
2486 PyObject
*taskHandlePy
= PyTuple_GetItem(args
, 0);
2487 ompd_task_handle_t
*task_handle
=
2488 (ompd_task_handle_t
*)(PyCapsule_GetPointer(taskHandlePy
, "TaskHandle"));
2490 ompd_word_t icv_value
;
2492 printf("Test: With Correct Arguments.\n");
2493 ompd_rc_t rc
= ompd_get_icv_from_scope(
2494 task_handle
, ompd_scope_task
,
2495 16 /*ompd_icv_thread_limit_var: check enum ompd_icv in omp-icv.cpp */,
2497 if (rc
!= ompd_rc_ok
) {
2498 printf("Failed. with return code = %d\n", rc
);
2501 printf("Success.\n");
2506 Test API: ompd_get_icv_string_from_scope
2509 1. #include <stdio.h>
2512 4. omp_set_num_threads(4);
2513 5. #pragma omp parallel
2515 7. printf("Parallel level 1, thread num = %d",
2516 omp_get_thread_num());
2525 ompdtestapi ompd_get_icv_string_from_scope
2527 PyObject
*test_ompd_get_icv_string_from_scope(PyObject
*self
, PyObject
*args
) {
2528 printf("Testing \"ompd_get_icv_string_from_scope\"...\n");
2530 PyObject
*addrSpaceTup
= PyTuple_GetItem(args
, 0);
2531 ompd_address_space_handle_t
*addr_handle
=
2532 (ompd_address_space_handle_t
*)PyCapsule_GetPointer(addrSpaceTup
,
2535 const char *icv_string
;
2537 printf("Test: With Correct Arguments.\n");
2538 ompd_rc_t rc
= ompd_get_icv_string_from_scope(
2539 addr_handle
, ompd_scope_address_space
,
2540 12 /*ompd_icv_tool_libraries_var: check enum ompd_icv in omp-icv.cpp */,
2542 if (rc
!= ompd_rc_ok
) {
2543 printf("Failed. with return code = %d\n", rc
);
2546 printf("Success.\n");
2548 // ompd_rc_bad_input if an unknown value is provided in icv_id.
2549 printf("Test: bad_input for unknown icv_id.\n");
2550 rc
= ompd_get_icv_string_from_scope(addr_handle
, ompd_scope_address_space
,
2551 99 /*wrong value*/, &icv_string
);
2552 if (rc
!= ompd_rc_bad_input
)
2553 printf("Failed. with return code = %d\n", rc
);
2555 printf("Success.\n");
2557 // Random checks with null and invalid args.
2559 ompd_rc_stale_handle: is returned when the specified handle is no
2561 ompd_rc_bad_input: is returned when the input parameters
2562 (other than handle) are invalid;
2563 ompd_rc_error: is returned when a fatal error occurred;
2566 printf("Test: Expecting ompd_rc_bad_input for NULL icv_string.\n");
2567 rc
= ompd_get_icv_string_from_scope(addr_handle
, ompd_scope_address_space
,
2568 12 /*ompd_icv_tool_libraries_var*/, NULL
);
2569 if (rc
!= ompd_rc_bad_input
)
2570 printf("Failed. with return code = %d\n", rc
);
2572 printf("Success.\n");
2574 printf("Test: Expecting ompd_rc_error for NULL handle.\n");
2575 rc
= ompd_get_icv_string_from_scope(NULL
, ompd_scope_address_space
,
2576 12 /*ompd_icv_tool_libraries_var*/,
2578 if (rc
!= ompd_rc_error
&& rc
!= ompd_rc_stale_handle
)
2579 printf("Failed. with return code = %d\n", rc
);
2581 printf("Success.\n");
2586 PyObject
*test_ompd_get_tool_data(PyObject
*self
, PyObject
*args
) {
2587 printf("Disabled: Testing Not enabled for \"ompd_get_tool_data\".\n");
2591 PyObject
*test_ompd_enumerate_states(PyObject
*self
, PyObject
*args
) {
2592 printf("Disabled: Testing Not enabled for \"ompd_enumerate_states\".\n");