@@ -1192,7 +1192,6 @@ kmp_task_t *__kmp_task_alloc(ident_t *loc_ref, kmp_int32 gtid,
1192
1192
kmp_task_t *task;
1193
1193
kmp_taskdata_t *taskdata;
1194
1194
kmp_info_t *thread = __kmp_threads[gtid];
1195
- kmp_info_t *encountering_thread = thread;
1196
1195
kmp_team_t *team = thread->th .th_team ;
1197
1196
kmp_taskdata_t *parent_task = thread->th .th_current_task ;
1198
1197
size_t shareds_offset;
@@ -1204,15 +1203,6 @@ kmp_task_t *__kmp_task_alloc(ident_t *loc_ref, kmp_int32 gtid,
1204
1203
if (__kmp_enable_hidden_helper) {
1205
1204
if (!TCR_4 (__kmp_init_hidden_helper))
1206
1205
__kmp_hidden_helper_initialize ();
1207
-
1208
- // For a hidden helper task encountered by a regular thread, we will push
1209
- // the task to the (gtid%__kmp_hidden_helper_threads_num)-th hidden helper
1210
- // thread.
1211
- if (!KMP_HIDDEN_HELPER_THREAD (gtid)) {
1212
- thread = __kmp_threads[KMP_GTID_TO_SHADOW_GTID (gtid)];
1213
- // We don't change the parent-child relation for hidden helper task as
1214
- // we need that to do per-task-region synchronization.
1215
- }
1216
1206
} else {
1217
1207
// If the hidden helper task is not enabled, reset the flag to FALSE.
1218
1208
flags->hidden_helper = FALSE ;
@@ -1235,8 +1225,7 @@ kmp_task_t *__kmp_task_alloc(ident_t *loc_ref, kmp_int32 gtid,
1235
1225
// Untied task encountered causes the TSC algorithm to check entire deque of
1236
1226
// the victim thread. If no untied task encountered, then checking the head
1237
1227
// of the deque should be enough.
1238
- KMP_CHECK_UPDATE (
1239
- encountering_thread->th .th_task_team ->tt .tt_untied_task_encountered , 1 );
1228
+ KMP_CHECK_UPDATE (thread->th .th_task_team ->tt .tt_untied_task_encountered , 1 );
1240
1229
}
1241
1230
1242
1231
// Detachable tasks are not proxy tasks yet but could be in the future. Doing
@@ -1250,32 +1239,30 @@ kmp_task_t *__kmp_task_alloc(ident_t *loc_ref, kmp_int32 gtid,
1250
1239
}
1251
1240
/* are we running in a sequential parallel or tskm_immediate_exec... we need
1252
1241
tasking support enabled */
1253
- if ((encountering_thread ->th .th_task_team ) == NULL ) {
1242
+ if ((thread ->th .th_task_team ) == NULL ) {
1254
1243
/* This should only happen if the team is serialized
1255
1244
setup a task team and propagate it to the thread */
1256
1245
KMP_DEBUG_ASSERT (team->t .t_serialized );
1257
1246
KA_TRACE (30 ,
1258
1247
(" T#%d creating task team in __kmp_task_alloc for proxy task\n " ,
1259
1248
gtid));
1260
- __kmp_task_team_setup (
1261
- encountering_thread, team,
1262
- 1 ); // 1 indicates setup the current team regardless of nthreads
1263
- encountering_thread->th .th_task_team =
1264
- team->t .t_task_team [encountering_thread->th .th_task_state ];
1249
+ // 1 indicates setup the current team regardless of nthreads
1250
+ __kmp_task_team_setup (thread, team, 1 );
1251
+ thread->th .th_task_team = team->t .t_task_team [thread->th .th_task_state ];
1265
1252
}
1266
- kmp_task_team_t *task_team = encountering_thread ->th .th_task_team ;
1253
+ kmp_task_team_t *task_team = thread ->th .th_task_team ;
1267
1254
1268
1255
/* tasking must be enabled now as the task might not be pushed */
1269
1256
if (!KMP_TASKING_ENABLED (task_team)) {
1270
1257
KA_TRACE (
1271
1258
30 ,
1272
1259
(" T#%d enabling tasking in __kmp_task_alloc for proxy task\n " , gtid));
1273
- __kmp_enable_tasking (task_team, encountering_thread );
1274
- kmp_int32 tid = encountering_thread ->th .th_info .ds .ds_tid ;
1260
+ __kmp_enable_tasking (task_team, thread );
1261
+ kmp_int32 tid = thread ->th .th_info .ds .ds_tid ;
1275
1262
kmp_thread_data_t *thread_data = &task_team->tt .tt_threads_data [tid];
1276
1263
// No lock needed since only owner can allocate
1277
1264
if (thread_data->td .td_deque == NULL ) {
1278
- __kmp_alloc_task_deque (encountering_thread , thread_data);
1265
+ __kmp_alloc_task_deque (thread , thread_data);
1279
1266
}
1280
1267
}
1281
1268
@@ -1300,11 +1287,11 @@ kmp_task_t *__kmp_task_alloc(ident_t *loc_ref, kmp_int32 gtid,
1300
1287
1301
1288
// Avoid double allocation here by combining shareds with taskdata
1302
1289
#if USE_FAST_MEMORY
1303
- taskdata = (kmp_taskdata_t *)__kmp_fast_allocate (
1304
- encountering_thread, shareds_offset + sizeof_shareds);
1290
+ taskdata = (kmp_taskdata_t *)__kmp_fast_allocate (thread, shareds_offset +
1291
+ sizeof_shareds);
1305
1292
#else /* ! USE_FAST_MEMORY */
1306
- taskdata = (kmp_taskdata_t *)__kmp_thread_malloc (
1307
- encountering_thread, shareds_offset + sizeof_shareds);
1293
+ taskdata = (kmp_taskdata_t *)__kmp_thread_malloc (thread, shareds_offset +
1294
+ sizeof_shareds);
1308
1295
#endif /* USE_FAST_MEMORY */
1309
1296
1310
1297
task = KMP_TASKDATA_TO_TASK (taskdata);
@@ -1331,7 +1318,7 @@ kmp_task_t *__kmp_task_alloc(ident_t *loc_ref, kmp_int32 gtid,
1331
1318
1332
1319
taskdata->td_task_id = KMP_GEN_TASK_ID ();
1333
1320
taskdata->td_team = thread->th .th_team ;
1334
- taskdata->td_alloc_thread = encountering_thread ;
1321
+ taskdata->td_alloc_thread = thread ;
1335
1322
taskdata->td_parent = parent_task;
1336
1323
taskdata->td_level = parent_task->td_level + 1 ; // increment nesting level
1337
1324
KMP_ATOMIC_ST_RLX (&taskdata->td_untied_count , 0 );
@@ -1345,10 +1332,16 @@ kmp_task_t *__kmp_task_alloc(ident_t *loc_ref, kmp_int32 gtid,
1345
1332
copy_icvs (&taskdata->td_icvs , &taskdata->td_parent ->td_icvs );
1346
1333
1347
1334
taskdata->td_flags = *flags;
1348
- taskdata->encountering_gtid = gtid;
1349
1335
taskdata->td_task_team = thread->th .th_task_team ;
1350
1336
taskdata->td_size_alloc = shareds_offset + sizeof_shareds;
1351
1337
taskdata->td_flags .tasktype = TASK_EXPLICIT;
1338
+ // If it is hidden helper task, we need to set the team and task team
1339
+ // correspondingly.
1340
+ if (flags->hidden_helper ) {
1341
+ kmp_info_t *shadow_thread = __kmp_threads[KMP_GTID_TO_SHADOW_GTID (gtid)];
1342
+ taskdata->td_team = shadow_thread->th .th_team ;
1343
+ taskdata->td_task_team = shadow_thread->th .th_task_team ;
1344
+ }
1352
1345
1353
1346
// GEH - TODO: fix this to copy parent task's value of tasking_ser flag
1354
1347
taskdata->td_flags .tasking_ser = (__kmp_tasking_mode == tskm_immediate_exec);
@@ -3957,7 +3950,7 @@ void __kmpc_give_task(kmp_task_t *ptask, kmp_int32 start = 0) {
3957
3950
3958
3951
// This should be similar to start_k = __kmp_get_random( thread ) % nthreads
3959
3952
// but we cannot use __kmp_get_random here
3960
- kmp_int32 start_k = start;
3953
+ kmp_int32 start_k = start % nthreads ;
3961
3954
kmp_int32 pass = 1 ;
3962
3955
kmp_int32 k = start_k;
3963
3956
0 commit comments