@@ -105,58 +105,8 @@ typedef int (*TargetDataFuncPtrTy)(ident_t *, DeviceTy &, int32_t, void **,
105
105
#ifdef __cplusplus
106
106
extern " C" {
107
107
#endif
108
- /* !
109
- * The ident structure that describes a source location.
110
- * The struct is identical to the one in the kmp.h file.
111
- * We maintain the same data structure for compatibility.
112
- */
113
- typedef void *omp_depend_t ;
114
- struct kmp_task ;
115
- typedef int32_t (*kmp_routine_entry_t )(int32_t , struct kmp_task *);
116
- typedef struct kmp_task {
117
- void *shareds;
118
- kmp_routine_entry_t routine;
119
- int32_t part_id;
120
- } kmp_task_t ;
121
-
122
- typedef struct kmp_tasking_flags { /* Total struct must be exactly 32 bits */
123
- /* Compiler flags */ /* Total compiler flags must be 16 bits */
124
- unsigned tiedness : 1 ; /* task is either tied (1) or untied (0) */
125
- unsigned final : 1 ; /* task is final(1) so execute immediately */
126
- unsigned merged_if0 : 1 ; /* no __kmpc_task_{begin/complete}_if0 calls in if0
127
- code path */
128
- unsigned destructors_thunk : 1 ; /* set if the compiler creates a thunk to
129
- invoke destructors from the runtime */
130
- unsigned proxy : 1 ; /* task is a proxy task (it will be executed outside the
131
- context of the RTL) */
132
- unsigned priority_specified : 1 ; /* set if the compiler provides priority
133
- setting for the task */
134
- unsigned detachable : 1 ; /* 1 == can detach */
135
- unsigned hidden_helper : 1 ; /* 1 == hidden helper task */
136
- unsigned reserved : 8 ; /* reserved for compiler use */
137
-
138
- /* Library flags */ /* Total library flags must be 16 bits */
139
- unsigned tasktype : 1 ; /* task is either explicit(1) or implicit (0) */
140
- unsigned task_serial : 1 ; // task is executed immediately (1) or deferred (0)
141
- unsigned tasking_ser : 1 ; // all tasks in team are either executed immediately
142
- // (1) or may be deferred (0)
143
- unsigned team_serial : 1 ; // entire team is serial (1) [1 thread] or parallel
144
- // (0) [>= 2 threads]
145
- /* If either team_serial or tasking_ser is set, task team may be NULL */
146
- /* Task State Flags: */
147
- unsigned started : 1 ; /* 1==started, 0==not started */
148
- unsigned executing : 1 ; /* 1==executing, 0==not executing */
149
- unsigned complete : 1 ; /* 1==complete, 0==not complete */
150
- unsigned freed : 1 ; /* 1==freed, 0==allocated */
151
- unsigned native : 1 ; /* 1==gcc-compiled task, 0==intel */
152
- unsigned reserved31 : 7 ; /* reserved for library use */
153
- } kmp_tasking_flags_t ;
154
-
155
- int32_t __kmpc_global_thread_num (void *) __attribute__((weak));
108
+
156
109
int __kmpc_get_target_offload (void ) __attribute__((weak));
157
- void **__kmpc_omp_get_target_async_handle_ptr (int32_t gtid)
158
- __attribute__((weak));
159
- bool __kmpc_omp_has_task_team (int32_t gtid) __attribute__((weak));
160
110
kmp_task_t *__kmpc_omp_task_alloc (ident_t *loc_ref, int32_t gtid, int32_t flags,
161
111
size_t sizeof_kmp_task_t ,
162
112
size_t sizeof_shareds,
@@ -248,8 +198,6 @@ struct TargetMemsetArgsTy {
248
198
// no constructors defined, because this is a PoD
249
199
};
250
200
251
- // Invalid GTID as defined by libomp; keep in sync
252
- #define KMP_GTID_DNE (-2 )
253
201
#ifdef __cplusplus
254
202
}
255
203
#endif
@@ -319,67 +267,4 @@ printKernelArguments(const ident_t *Loc, const int64_t DeviceId,
319
267
}
320
268
}
321
269
322
- // Wrapper for task stored async info objects.
323
- class TaskAsyncInfoWrapperTy {
324
- const int ExecThreadID = KMP_GTID_DNE;
325
- AsyncInfoTy LocalAsyncInfo;
326
- AsyncInfoTy *AsyncInfo = &LocalAsyncInfo;
327
- void **TaskAsyncInfoPtr = nullptr ;
328
-
329
- public:
330
- TaskAsyncInfoWrapperTy (DeviceTy &Device)
331
- : ExecThreadID(__kmpc_global_thread_num(NULL )), LocalAsyncInfo(Device) {
332
- // If we failed to acquired the current global thread id, we cannot
333
- // re-enqueue the current task. Thus we should use the local blocking async
334
- // info.
335
- if (ExecThreadID == KMP_GTID_DNE)
336
- return ;
337
-
338
- // Only tasks with an assigned task team can be re-enqueue and thus can
339
- // use the non-blocking synchronization scheme. Thus we should use the local
340
- // blocking async info, if we don´t have one.
341
- if (!__kmpc_omp_has_task_team (ExecThreadID))
342
- return ;
343
-
344
- // Acquire a pointer to the AsyncInfo stored inside the current task being
345
- // executed.
346
- TaskAsyncInfoPtr = __kmpc_omp_get_target_async_handle_ptr (ExecThreadID);
347
-
348
- // If we cannot acquire such pointer, fallback to using the local blocking
349
- // async info.
350
- if (!TaskAsyncInfoPtr)
351
- return ;
352
-
353
- // When creating a new task async info, the task handle must always be
354
- // invalid. We must never overwrite any task async handle and there should
355
- // never be any valid handle store inside the task at this point.
356
- assert ((*TaskAsyncInfoPtr) == nullptr &&
357
- " Task async handle is not empty when dispatching new device "
358
- " operations. The handle was not cleared properly or "
359
- " __tgt_target_nowait_query should have been called!" );
360
-
361
- // If no valid async handle is present, a new AsyncInfo will be allocated
362
- // and stored in the current task.
363
- AsyncInfo = new AsyncInfoTy (Device, AsyncInfoTy::SyncTy::NON_BLOCKING);
364
- *TaskAsyncInfoPtr = (void *)AsyncInfo;
365
- }
366
-
367
- ~TaskAsyncInfoWrapperTy () {
368
- // Local async info destruction is automatically handled by ~AsyncInfoTy.
369
- if (AsyncInfo == &LocalAsyncInfo)
370
- return ;
371
-
372
- // If the are device operations still pending, return immediately without
373
- // deallocating the handle.
374
- if (!AsyncInfo->isDone ())
375
- return ;
376
-
377
- // Delete the handle and unset it from the OpenMP task data.
378
- delete AsyncInfo;
379
- *TaskAsyncInfoPtr = nullptr ;
380
- }
381
-
382
- operator AsyncInfoTy &() { return *AsyncInfo; }
383
- };
384
-
385
270
#endif
0 commit comments