@@ -361,12 +361,9 @@ static
361
361
#endif
362
362
}
363
363
364
- #ifndef KMP_DEBUG
365
- static
366
- #endif /* KMP_DEBUG */
367
- void
368
- __kmp_GOMP_fork_call (ident_t *loc, int gtid, void (*unwrapped_task)(void *),
369
- microtask_t wrapper, int argc, ...) {
364
+ static void __kmp_GOMP_fork_call (ident_t *loc, int gtid, unsigned num_threads,
365
+ unsigned flags, void (*unwrapped_task)(void *),
366
+ microtask_t wrapper, int argc, ...) {
370
367
int rc;
371
368
kmp_info_t *thr = __kmp_threads[gtid];
372
369
kmp_team_t *team = thr->th .th_team ;
@@ -375,6 +372,10 @@ static
375
372
va_list ap;
376
373
va_start (ap, argc);
377
374
375
+ if (num_threads != 0 )
376
+ __kmp_push_num_threads (loc, gtid, num_threads);
377
+ if (flags != 0 )
378
+ __kmp_push_proc_bind (loc, gtid, (kmp_proc_bind_t )flags);
378
379
rc = __kmp_fork_call (loc, gtid, fork_context_gnu, argc, wrapper,
379
380
__kmp_invoke_task_func, kmp_va_addr_of (ap));
380
381
@@ -403,14 +404,6 @@ static
403
404
#endif
404
405
}
405
406
406
- static void __kmp_GOMP_serialized_parallel (ident_t *loc, kmp_int32 gtid,
407
- void (*task)(void *)) {
408
- #if OMPT_SUPPORT
409
- OMPT_STORE_RETURN_ADDRESS (gtid);
410
- #endif
411
- __kmp_serialized_parallel (loc, gtid);
412
- }
413
-
414
407
void KMP_EXPAND_NAME (KMP_API_NAME_GOMP_PARALLEL_START)(void (*task)(void *),
415
408
void *data,
416
409
unsigned num_threads) {
@@ -428,18 +421,9 @@ void KMP_EXPAND_NAME(KMP_API_NAME_GOMP_PARALLEL_START)(void (*task)(void *),
428
421
429
422
MKLOC (loc, " GOMP_parallel_start" );
430
423
KA_TRACE (20 , (" GOMP_parallel_start: T#%d\n " , gtid));
431
-
432
- if (__kmpc_ok_to_fork (&loc) && (num_threads != 1 )) {
433
- if (num_threads != 0 ) {
434
- __kmp_push_num_threads (&loc, gtid, num_threads);
435
- }
436
- __kmp_GOMP_fork_call (&loc, gtid, task,
437
- (microtask_t )__kmp_GOMP_microtask_wrapper, 2 , task,
438
- data);
439
- } else {
440
- __kmp_GOMP_serialized_parallel (&loc, gtid, task);
441
- }
442
-
424
+ __kmp_GOMP_fork_call (&loc, gtid, num_threads, 0u , task,
425
+ (microtask_t )__kmp_GOMP_microtask_wrapper, 2 , task,
426
+ data);
443
427
#if OMPT_SUPPORT
444
428
if (ompt_enabled.enabled ) {
445
429
__ompt_get_task_info_internal (0 , NULL , NULL , &frame, NULL , NULL );
@@ -460,25 +444,22 @@ void KMP_EXPAND_NAME(KMP_API_NAME_GOMP_PARALLEL_END)(void) {
460
444
if (!thr->th .th_team ->t .t_serialized ) {
461
445
__kmp_run_after_invoked_task (gtid, __kmp_tid_from_gtid (gtid), thr,
462
446
thr->th .th_team );
463
-
447
+ }
464
448
#if OMPT_SUPPORT
465
- if (ompt_enabled.enabled ) {
466
- // Implicit task is finished here, in the barrier we might schedule
467
- // deferred tasks,
468
- // these don't see the implicit task on the stack
469
- OMPT_CUR_TASK_INFO (thr)->frame .exit_frame = ompt_data_none;
470
- }
449
+ if (ompt_enabled.enabled ) {
450
+ // Implicit task is finished here, in the barrier we might schedule
451
+ // deferred tasks,
452
+ // these don't see the implicit task on the stack
453
+ OMPT_CUR_TASK_INFO (thr)->frame .exit_frame = ompt_data_none;
454
+ }
471
455
#endif
472
456
473
- __kmp_join_call (&loc, gtid
457
+ __kmp_join_call (&loc, gtid
474
458
#if OMPT_SUPPORT
475
- ,
476
- fork_context_gnu
459
+ ,
460
+ fork_context_gnu
477
461
#endif
478
- );
479
- } else {
480
- __kmpc_end_serialized_parallel (&loc, gtid);
481
- }
462
+ );
482
463
}
483
464
484
465
// Loop worksharing constructs
@@ -1073,19 +1054,11 @@ LOOP_DOACROSS_RUNTIME_START_ULL(
1073
1054
\
1074
1055
ompt_pre (); \
1075
1056
\
1076
- if (__kmpc_ok_to_fork (&loc) && (num_threads != 1 )) { \
1077
- if (num_threads != 0 ) { \
1078
- __kmp_push_num_threads (&loc, gtid, num_threads); \
1079
- } \
1080
- __kmp_GOMP_fork_call (&loc, gtid, task, \
1081
- (microtask_t )__kmp_GOMP_parallel_microtask_wrapper, \
1082
- 9 , task, data, num_threads, &loc, (schedule), lb, \
1083
- (str > 0 ) ? (ub - 1 ) : (ub + 1 ), str, chunk_sz); \
1084
- IF_OMPT_SUPPORT (OMPT_STORE_RETURN_ADDRESS (gtid)); \
1085
- } else { \
1086
- __kmp_GOMP_serialized_parallel (&loc, gtid, task); \
1087
- IF_OMPT_SUPPORT (OMPT_STORE_RETURN_ADDRESS (gtid)); \
1088
- } \
1057
+ __kmp_GOMP_fork_call (&loc, gtid, num_threads, 0u , task, \
1058
+ (microtask_t )__kmp_GOMP_parallel_microtask_wrapper, \
1059
+ 9 , task, data, num_threads, &loc, (schedule), lb, \
1060
+ (str > 0 ) ? (ub - 1 ) : (ub + 1 ), str, chunk_sz); \
1061
+ IF_OMPT_SUPPORT (OMPT_STORE_RETURN_ADDRESS (gtid)); \
1089
1062
\
1090
1063
KMP_DISPATCH_INIT (&loc, gtid, (schedule), lb, \
1091
1064
(str > 0 ) ? (ub - 1 ) : (ub + 1 ), str, chunk_sz, \
@@ -1332,17 +1305,10 @@ void KMP_EXPAND_NAME(KMP_API_NAME_GOMP_PARALLEL_SECTIONS_START)(
1332
1305
MKLOC (loc, " GOMP_parallel_sections_start" );
1333
1306
KA_TRACE (20 , (" GOMP_parallel_sections_start: T#%d\n " , gtid));
1334
1307
1335
- if (__kmpc_ok_to_fork (&loc) && (num_threads != 1 )) {
1336
- if (num_threads != 0 ) {
1337
- __kmp_push_num_threads (&loc, gtid, num_threads);
1338
- }
1339
- __kmp_GOMP_fork_call (&loc, gtid, task,
1340
- (microtask_t )__kmp_GOMP_parallel_microtask_wrapper, 9 ,
1341
- task, data, num_threads, &loc, kmp_nm_dynamic_chunked,
1342
- (kmp_int)1 , (kmp_int)count, (kmp_int)1 , (kmp_int)1 );
1343
- } else {
1344
- __kmp_GOMP_serialized_parallel (&loc, gtid, task);
1345
- }
1308
+ __kmp_GOMP_fork_call (&loc, gtid, num_threads, 0u , task,
1309
+ (microtask_t )__kmp_GOMP_parallel_microtask_wrapper, 9 ,
1310
+ task, data, num_threads, &loc, kmp_nm_dynamic_chunked,
1311
+ (kmp_int)1 , (kmp_int)count, (kmp_int)1 , (kmp_int)1 );
1346
1312
1347
1313
#if OMPT_SUPPORT
1348
1314
if (ompt_enabled.enabled ) {
@@ -1403,19 +1369,9 @@ void KMP_EXPAND_NAME(KMP_API_NAME_GOMP_PARALLEL)(void (*task)(void *),
1403
1369
OMPT_STORE_RETURN_ADDRESS (gtid);
1404
1370
}
1405
1371
#endif
1406
- if (__kmpc_ok_to_fork (&loc) && (num_threads != 1 )) {
1407
- if (num_threads != 0 ) {
1408
- __kmp_push_num_threads (&loc, gtid, num_threads);
1409
- }
1410
- if (flags != 0 ) {
1411
- __kmp_push_proc_bind (&loc, gtid, (kmp_proc_bind_t )flags);
1412
- }
1413
- __kmp_GOMP_fork_call (&loc, gtid, task,
1414
- (microtask_t )__kmp_GOMP_microtask_wrapper, 2 , task,
1415
- data);
1416
- } else {
1417
- __kmp_GOMP_serialized_parallel (&loc, gtid, task);
1418
- }
1372
+ __kmp_GOMP_fork_call (&loc, gtid, num_threads, flags, task,
1373
+ (microtask_t )__kmp_GOMP_microtask_wrapper, 2 , task,
1374
+ data);
1419
1375
#if OMPT_SUPPORT
1420
1376
if (ompt_enabled.enabled ) {
1421
1377
task_info = __ompt_get_task_info_object (0 );
@@ -1450,20 +1406,10 @@ void KMP_EXPAND_NAME(KMP_API_NAME_GOMP_PARALLEL_SECTIONS)(void (*task)(void *),
1450
1406
OMPT_STORE_RETURN_ADDRESS (gtid);
1451
1407
#endif
1452
1408
1453
- if (__kmpc_ok_to_fork (&loc) && (num_threads != 1 )) {
1454
- if (num_threads != 0 ) {
1455
- __kmp_push_num_threads (&loc, gtid, num_threads);
1456
- }
1457
- if (flags != 0 ) {
1458
- __kmp_push_proc_bind (&loc, gtid, (kmp_proc_bind_t )flags);
1459
- }
1460
- __kmp_GOMP_fork_call (&loc, gtid, task,
1461
- (microtask_t )__kmp_GOMP_parallel_microtask_wrapper, 9 ,
1462
- task, data, num_threads, &loc, kmp_nm_dynamic_chunked,
1463
- (kmp_int)1 , (kmp_int)count, (kmp_int)1 , (kmp_int)1 );
1464
- } else {
1465
- __kmp_GOMP_serialized_parallel (&loc, gtid, task);
1466
- }
1409
+ __kmp_GOMP_fork_call (&loc, gtid, num_threads, flags, task,
1410
+ (microtask_t )__kmp_GOMP_parallel_microtask_wrapper, 9 ,
1411
+ task, data, num_threads, &loc, kmp_nm_dynamic_chunked,
1412
+ (kmp_int)1 , (kmp_int)count, (kmp_int)1 , (kmp_int)1 );
1467
1413
1468
1414
#if OMPT_SUPPORT
1469
1415
OMPT_STORE_RETURN_ADDRESS (gtid);
@@ -1488,20 +1434,10 @@ void KMP_EXPAND_NAME(KMP_API_NAME_GOMP_PARALLEL_SECTIONS)(void (*task)(void *),
1488
1434
gtid, lb, ub, str, chunk_sz)); \
1489
1435
\
1490
1436
ompt_pre (); \
1491
- if (__kmpc_ok_to_fork (&loc) && (num_threads != 1 )) { \
1492
- if (num_threads != 0 ) { \
1493
- __kmp_push_num_threads (&loc, gtid, num_threads); \
1494
- } \
1495
- if (flags != 0 ) { \
1496
- __kmp_push_proc_bind (&loc, gtid, (kmp_proc_bind_t )flags); \
1497
- } \
1498
- __kmp_GOMP_fork_call (&loc, gtid, task, \
1499
- (microtask_t )__kmp_GOMP_parallel_microtask_wrapper, \
1500
- 9 , task, data, num_threads, &loc, (schedule), lb, \
1501
- (str > 0 ) ? (ub - 1 ) : (ub + 1 ), str, chunk_sz); \
1502
- } else { \
1503
- __kmp_GOMP_serialized_parallel (&loc, gtid, task); \
1504
- } \
1437
+ __kmp_GOMP_fork_call (&loc, gtid, num_threads, flags, task, \
1438
+ (microtask_t )__kmp_GOMP_parallel_microtask_wrapper, \
1439
+ 9 , task, data, num_threads, &loc, (schedule), lb, \
1440
+ (str > 0 ) ? (ub - 1 ) : (ub + 1 ), str, chunk_sz); \
1505
1441
\
1506
1442
IF_OMPT_SUPPORT (OMPT_STORE_RETURN_ADDRESS (gtid);) \
1507
1443
KMP_DISPATCH_INIT (&loc, gtid, (schedule), lb, \
@@ -1856,6 +1792,25 @@ void KMP_EXPAND_NAME(KMP_API_NAME_GOMP_DOACROSS_ULL_WAIT)(
1856
1792
va_end (args);
1857
1793
}
1858
1794
1795
+ // fn: the function each master thread of new team will call
1796
+ // data: argument to fn
1797
+ // num_teams, thread_limit: max bounds on respective ICV
1798
+ // flags: unused
1799
+ void KMP_EXPAND_NAME (KMP_API_NAME_GOMP_TEAMS_REG)(void (*fn)(void *),
1800
+ void *data,
1801
+ unsigned num_teams,
1802
+ unsigned thread_limit,
1803
+ unsigned flags) {
1804
+ MKLOC (loc, " GOMP_teams_reg" );
1805
+ int gtid = __kmp_entry_gtid ();
1806
+ KA_TRACE (20 , (" GOMP_teams_reg: T#%d num_teams=%u thread_limit=%u flag=%u\n " ,
1807
+ gtid, num_teams, thread_limit, flags));
1808
+ __kmpc_push_num_teams (&loc, gtid, num_teams, thread_limit);
1809
+ __kmpc_fork_teams (&loc, 2 , (microtask_t )__kmp_GOMP_microtask_wrapper, fn,
1810
+ data);
1811
+ KA_TRACE (20 , (" GOMP_teams_reg exit: T#%d\n " , gtid));
1812
+ }
1813
+
1859
1814
/* The following sections of code create aliases for the GOMP_* functions, then
1860
1815
create versioned symbols using the assembler directive .symver. This is only
1861
1816
pertinent for ELF .so library. The KMP_VERSION_SYMBOL macro is defined in
@@ -2027,6 +1982,7 @@ KMP_VERSION_SYMBOL(KMP_API_NAME_GOMP_PARALLEL_LOOP_NONMONOTONIC_RUNTIME, 50,
2027
1982
" GOMP_5.0" );
2028
1983
KMP_VERSION_SYMBOL (KMP_API_NAME_GOMP_PARALLEL_LOOP_MAYBE_NONMONOTONIC_RUNTIME,
2029
1984
50 , " GOMP_5.0" );
1985
+ KMP_VERSION_SYMBOL (KMP_API_NAME_GOMP_TEAMS_REG, 50 , " GOMP_5.0" );
2030
1986
2031
1987
#endif // KMP_USE_VERSION_SYMBOLS
2032
1988
0 commit comments