Changeset View
Changeset View
Standalone View
Standalone View
openmp/libomptarget/deviceRTLs/common/src/support.cu
Show First 20 Lines • Show All 47 Lines • ▼ Show 20 Lines | |||||
// Thread id is 0 indexed. | // Thread id is 0 indexed. | ||||
// E.g: If NumThreads is 33, master id is 32. | // E.g: If NumThreads is 33, master id is 32. | ||||
// If NumThreads is 64, master id is 32. | // If NumThreads is 64, master id is 32. | ||||
// If NumThreads is 97, master id is 96. | // If NumThreads is 97, master id is 96. | ||||
// If NumThreads is 1024, master id is 992. | // If NumThreads is 1024, master id is 992. | ||||
// | // | ||||
// Called in Generic Execution Mode only. | // Called in Generic Execution Mode only. | ||||
int GetMasterThreadID() { | int GetMasterThreadID() { | ||||
return (GetNumberOfThreadsInBlock() - 1) & ~(WARPSIZE - 1); | return (__kmpc_get_hardware_num_threads_in_block() - 1) & ~(WARPSIZE - 1); | ||||
} | } | ||||
// The last warp is reserved for the master; other warps are workers. | // The last warp is reserved for the master; other warps are workers. | ||||
// Called in Generic Execution Mode only. | // Called in Generic Execution Mode only. | ||||
int GetNumberOfWorkersInTeam() { return GetMasterThreadID(); } | int GetNumberOfWorkersInTeam() { return GetMasterThreadID(); } | ||||
//////////////////////////////////////////////////////////////////////////////// | //////////////////////////////////////////////////////////////////////////////// | ||||
// get thread id in team | // get thread id in team | ||||
Show All 39 Lines | |||||
int GetNumberOfOmpThreads(bool isSPMDExecutionMode) { | int GetNumberOfOmpThreads(bool isSPMDExecutionMode) { | ||||
// omp_num_threads | // omp_num_threads | ||||
int rc; | int rc; | ||||
int Level = parallelLevel[GetWarpId()]; | int Level = parallelLevel[GetWarpId()]; | ||||
if (Level != OMP_ACTIVE_PARALLEL_LEVEL + 1) { | if (Level != OMP_ACTIVE_PARALLEL_LEVEL + 1) { | ||||
rc = 1; | rc = 1; | ||||
} else if (isSPMDExecutionMode) { | } else if (isSPMDExecutionMode) { | ||||
rc = GetNumberOfThreadsInBlock(); | rc = __kmpc_get_hardware_num_threads_in_block(); | ||||
} else { | } else { | ||||
rc = threadsInTeam; | rc = threadsInTeam; | ||||
} | } | ||||
return rc; | return rc; | ||||
} | } | ||||
//////////////////////////////////////////////////////////////////////////////// | //////////////////////////////////////////////////////////////////////////////// | ||||
// Team id linked to OpenMP | // Team id linked to OpenMP | ||||
int GetOmpTeamId() { | int GetOmpTeamId() { | ||||
// omp_team_num | // omp_team_num | ||||
return GetBlockIdInKernel(); // assume 1 block per team | return GetBlockIdInKernel(); // assume 1 block per team | ||||
} | } | ||||
int GetNumberOfOmpTeams() { | int GetNumberOfOmpTeams() { | ||||
// omp_num_teams | // omp_num_teams | ||||
return GetNumberOfBlocksInKernel(); // assume 1 block per team | return __kmpc_get_hardware_num_blocks(); // assume 1 block per team | ||||
} | } | ||||
//////////////////////////////////////////////////////////////////////////////// | //////////////////////////////////////////////////////////////////////////////// | ||||
// Masters | // Masters | ||||
int IsTeamMaster(int ompThreadId) { return (ompThreadId == 0); } | int IsTeamMaster(int ompThreadId) { return (ompThreadId == 0); } | ||||
//////////////////////////////////////////////////////////////////////////////// | //////////////////////////////////////////////////////////////////////////////// | ||||
Show All 25 Lines | |||||
//////////////////////////////////////////////////////////////////////////////// | //////////////////////////////////////////////////////////////////////////////// | ||||
// get OpenMP number of procs | // get OpenMP number of procs | ||||
// Get the number of processors in the device. | // Get the number of processors in the device. | ||||
int GetNumberOfProcsInDevice(bool isSPMDExecutionMode) { | int GetNumberOfProcsInDevice(bool isSPMDExecutionMode) { | ||||
if (!isSPMDExecutionMode) | if (!isSPMDExecutionMode) | ||||
return GetNumberOfWorkersInTeam(); | return GetNumberOfWorkersInTeam(); | ||||
return GetNumberOfThreadsInBlock(); | return __kmpc_get_hardware_num_threads_in_block(); | ||||
} | } | ||||
int GetNumberOfProcsInTeam(bool isSPMDExecutionMode) { | int GetNumberOfProcsInTeam(bool isSPMDExecutionMode) { | ||||
return GetNumberOfProcsInDevice(isSPMDExecutionMode); | return GetNumberOfProcsInDevice(isSPMDExecutionMode); | ||||
} | } | ||||
//////////////////////////////////////////////////////////////////////////////// | //////////////////////////////////////////////////////////////////////////////// | ||||
// Memory | // Memory | ||||
▲ Show 20 Lines • Show All 50 Lines • Show Last 20 Lines |