Changeset View
Changeset View
Standalone View
Standalone View
openmp/trunk/libomptarget/deviceRTLs/nvptx/src/loop.cu
Show First 20 Lines • Show All 234 Lines • ▼ Show 20 Lines | INLINE static void dispatch_init(kmp_sched_t schedule, T lb, T ub, ST st, | ||||
* various dynamic cases. (In paritcular, whether or not a stealing scheme | * various dynamic cases. (In paritcular, whether or not a stealing scheme | ||||
* is legal). | * is legal). | ||||
*/ | */ | ||||
schedule = SCHEDULE_WITHOUT_MODIFIERS(schedule); | schedule = SCHEDULE_WITHOUT_MODIFIERS(schedule); | ||||
// Process schedule. | // Process schedule. | ||||
if (tnum == 1 || tripCount <= 1 || OrderedSchedule(schedule)) { | if (tnum == 1 || tripCount <= 1 || OrderedSchedule(schedule)) { | ||||
PRINT(LD_LOOP, | PRINT(LD_LOOP, | ||||
"go sequential as tnum=%d, trip count %lld, ordered sched=%d\n", | "go sequential as tnum=%ld, trip count %lld, ordered sched=%d\n", | ||||
tnum, P64(tripCount), schedule); | (long)tnum, P64(tripCount), schedule); | ||||
schedule = kmp_sched_static_chunk; | schedule = kmp_sched_static_chunk; | ||||
chunk = tripCount; // one thread gets the whole loop | chunk = tripCount; // one thread gets the whole loop | ||||
} else if (schedule == kmp_sched_runtime) { | } else if (schedule == kmp_sched_runtime) { | ||||
// process runtime | // process runtime | ||||
omp_sched_t rtSched = currTaskDescr->GetRuntimeSched(); | omp_sched_t rtSched = currTaskDescr->GetRuntimeSched(); | ||||
chunk = currTaskDescr->RuntimeChunkSize(); | chunk = currTaskDescr->RuntimeChunkSize(); | ||||
switch (rtSched) { | switch (rtSched) { | ||||
▲ Show 20 Lines • Show All 43 Lines • ▼ Show 20 Lines | if (schedule == kmp_sched_static_chunk) { | ||||
T threadId = GetOmpThreadId(tid, isSPMDMode(), isRuntimeUninitialized()); | T threadId = GetOmpThreadId(tid, isSPMDMode(), isRuntimeUninitialized()); | ||||
int lastiter = 0; | int lastiter = 0; | ||||
ForStaticChunk(lastiter, lb, ub, stride, chunk, threadId, tnum); | ForStaticChunk(lastiter, lb, ub, stride, chunk, threadId, tnum); | ||||
// save computed params | // save computed params | ||||
omptarget_nvptx_threadPrivateContext->Chunk(tid) = chunk; | omptarget_nvptx_threadPrivateContext->Chunk(tid) = chunk; | ||||
omptarget_nvptx_threadPrivateContext->NextLowerBound(tid) = lb; | omptarget_nvptx_threadPrivateContext->NextLowerBound(tid) = lb; | ||||
omptarget_nvptx_threadPrivateContext->Stride(tid) = stride; | omptarget_nvptx_threadPrivateContext->Stride(tid) = stride; | ||||
PRINT(LD_LOOP, | PRINT(LD_LOOP, | ||||
"dispatch init (static chunk) : num threads = %d, ub = %lld," | "dispatch init (static chunk) : num threads = %d, ub = %" PRId64 "," | ||||
"next lower bound = %lld, stride = %lld\n", | "next lower bound = %llu, stride = %llu\n", | ||||
GetNumberOfOmpThreads(tid, isSPMDMode(), isRuntimeUninitialized()), | GetNumberOfOmpThreads(tid, isSPMDMode(), isRuntimeUninitialized()), | ||||
omptarget_nvptx_threadPrivateContext->LoopUpperBound(tid), | omptarget_nvptx_threadPrivateContext->LoopUpperBound(tid), | ||||
omptarget_nvptx_threadPrivateContext->NextLowerBound(tid), | omptarget_nvptx_threadPrivateContext->NextLowerBound(tid), | ||||
omptarget_nvptx_threadPrivateContext->Stride(tid)); | omptarget_nvptx_threadPrivateContext->Stride(tid)); | ||||
} else if (schedule == kmp_sched_static_nochunk) { | } else if (schedule == kmp_sched_static_nochunk) { | ||||
ASSERT0(LT_FUSSY, chunk == 0, "bad chunk value"); | ASSERT0(LT_FUSSY, chunk == 0, "bad chunk value"); | ||||
// save ub | // save ub | ||||
omptarget_nvptx_threadPrivateContext->LoopUpperBound(tid) = ub; | omptarget_nvptx_threadPrivateContext->LoopUpperBound(tid) = ub; | ||||
// compute static chunk | // compute static chunk | ||||
ST stride; | ST stride; | ||||
T threadId = GetOmpThreadId(tid, isSPMDMode(), isRuntimeUninitialized()); | T threadId = GetOmpThreadId(tid, isSPMDMode(), isRuntimeUninitialized()); | ||||
int lastiter = 0; | int lastiter = 0; | ||||
ForStaticNoChunk(lastiter, lb, ub, stride, chunk, threadId, tnum); | ForStaticNoChunk(lastiter, lb, ub, stride, chunk, threadId, tnum); | ||||
// save computed params | // save computed params | ||||
omptarget_nvptx_threadPrivateContext->Chunk(tid) = chunk; | omptarget_nvptx_threadPrivateContext->Chunk(tid) = chunk; | ||||
omptarget_nvptx_threadPrivateContext->NextLowerBound(tid) = lb; | omptarget_nvptx_threadPrivateContext->NextLowerBound(tid) = lb; | ||||
omptarget_nvptx_threadPrivateContext->Stride(tid) = stride; | omptarget_nvptx_threadPrivateContext->Stride(tid) = stride; | ||||
PRINT(LD_LOOP, | PRINT(LD_LOOP, | ||||
"dispatch init (static nochunk) : num threads = %d, ub = %lld," | "dispatch init (static nochunk) : num threads = %d, ub = %" PRId64 "," | ||||
"next lower bound = %lld, stride = %lld\n", | "next lower bound = %llu, stride = %llu\n", | ||||
GetNumberOfOmpThreads(tid, isSPMDMode(), isRuntimeUninitialized()), | GetNumberOfOmpThreads(tid, isSPMDMode(), isRuntimeUninitialized()), | ||||
omptarget_nvptx_threadPrivateContext->LoopUpperBound(tid), | omptarget_nvptx_threadPrivateContext->LoopUpperBound(tid), | ||||
omptarget_nvptx_threadPrivateContext->NextLowerBound(tid), | omptarget_nvptx_threadPrivateContext->NextLowerBound(tid), | ||||
omptarget_nvptx_threadPrivateContext->Stride(tid)); | omptarget_nvptx_threadPrivateContext->Stride(tid)); | ||||
} else if (schedule == kmp_sched_dynamic || schedule == kmp_sched_guided) { | } else if (schedule == kmp_sched_dynamic || schedule == kmp_sched_guided) { | ||||
if (chunk < 1) | if (chunk < 1) | ||||
chunk = 1; | chunk = 1; | ||||
Counter eventNum = ((tripCount - 1) / chunk) + 1; // number of chunks | Counter eventNum = ((tripCount - 1) / chunk) + 1; // number of chunks | ||||
// but each thread (but one) must discover that it is last | // but each thread (but one) must discover that it is last | ||||
eventNum += tnum; | eventNum += tnum; | ||||
omptarget_nvptx_threadPrivateContext->Chunk(tid) = chunk; | omptarget_nvptx_threadPrivateContext->Chunk(tid) = chunk; | ||||
omptarget_nvptx_threadPrivateContext->EventsNumber(tid) = eventNum; | omptarget_nvptx_threadPrivateContext->EventsNumber(tid) = eventNum; | ||||
PRINT(LD_LOOP, | PRINT(LD_LOOP, | ||||
"dispatch init (dyn) : num threads = %d, ub = %lld, chunk %lld, " | "dispatch init (dyn) : num threads = %d, ub = %" PRId64 ", chunk %" PRIu64 ", " | ||||
"events number = %lld\n", | "events number = %llu\n", | ||||
GetNumberOfOmpThreads(tid, isSPMDMode(), isRuntimeUninitialized()), | GetNumberOfOmpThreads(tid, isSPMDMode(), isRuntimeUninitialized()), | ||||
omptarget_nvptx_threadPrivateContext->LoopUpperBound(tid), | omptarget_nvptx_threadPrivateContext->LoopUpperBound(tid), | ||||
omptarget_nvptx_threadPrivateContext->Chunk(tid), | omptarget_nvptx_threadPrivateContext->Chunk(tid), | ||||
omptarget_nvptx_threadPrivateContext->EventsNumber(tid)); | omptarget_nvptx_threadPrivateContext->EventsNumber(tid)); | ||||
} | } | ||||
} | } | ||||
//////////////////////////////////////////////////////////////////////////////// | //////////////////////////////////////////////////////////////////////////////// | ||||
▲ Show 20 Lines • Show All 422 Lines • Show Last 20 Lines |