@@ -172,7 +172,7 @@ static const omp::GV &getGridValue(const Triple &T, Function *Kernel) {
172172// / arguments.
173173static OMPScheduleType
174174getOpenMPBaseScheduleType (llvm::omp::ScheduleKind ClauseKind, bool HasChunks,
175- bool HasSimdModifier, bool HasDistScheduleChunks ) {
175+ bool HasSimdModifier) {
176176 // Currently, the default schedule it static.
177177 switch (ClauseKind) {
178178 case OMP_SCHEDULE_Default:
@@ -190,7 +190,7 @@ getOpenMPBaseScheduleType(llvm::omp::ScheduleKind ClauseKind, bool HasChunks,
190190 return HasSimdModifier ? OMPScheduleType::BaseRuntimeSimd
191191 : OMPScheduleType::BaseRuntime;
192192 case OMP_SCHEDULE_Distribute:
193- return HasDistScheduleChunks ? OMPScheduleType::BaseDistributeChunked
193+ return HasChunks ? OMPScheduleType::BaseDistributeChunked
194194 : OMPScheduleType::BaseDistribute;
195195 }
196196 llvm_unreachable (" unhandled schedule clause argument" );
@@ -260,10 +260,9 @@ getOpenMPMonotonicityScheduleType(OMPScheduleType ScheduleType,
260260static OMPScheduleType
261261computeOpenMPScheduleType (ScheduleKind ClauseKind, bool HasChunks,
262262 bool HasSimdModifier, bool HasMonotonicModifier,
263- bool HasNonmonotonicModifier, bool HasOrderedClause,
264- bool HasDistScheduleChunks) {
263+ bool HasNonmonotonicModifier, bool HasOrderedClause) {
265264 OMPScheduleType BaseSchedule = getOpenMPBaseScheduleType (
266- ClauseKind, HasChunks, HasSimdModifier, HasDistScheduleChunks );
265+ ClauseKind, HasChunks, HasSimdModifier);
267266 OMPScheduleType OrderedSchedule =
268267 getOpenMPOrderingScheduleType (BaseSchedule, HasOrderedClause);
269268 OMPScheduleType Result = getOpenMPMonotonicityScheduleType (
@@ -4643,8 +4642,7 @@ static FunctionCallee getKmpcForStaticInitForType(Type *Ty, Module &M,
46434642
46444643OpenMPIRBuilder::InsertPointOrErrorTy OpenMPIRBuilder::applyStaticWorkshareLoop (
46454644 DebugLoc DL, CanonicalLoopInfo *CLI, InsertPointTy AllocaIP,
4646- WorksharingLoopType LoopType, bool NeedsBarrier, bool HasDistSchedule,
4647- OMPScheduleType DistScheduleSchedType) {
4645+ WorksharingLoopType LoopType, bool NeedsBarrier, bool HasDistSchedule) {
46484646 assert (CLI->isValid () && " Requires a valid canonical loop" );
46494647 assert (!isConflictIP (AllocaIP, CLI->getPreheaderIP ()) &&
46504648 " Require dedicated allocate IP" );
@@ -4714,12 +4712,6 @@ OpenMPIRBuilder::InsertPointOrErrorTy OpenMPIRBuilder::applyStaticWorkshareLoop(
47144712 Builder.CreateCall (StaticInit, Args);
47154713 };
47164714 BuildInitCall (SchedulingType, Builder);
4717- if (HasDistSchedule &&
4718- LoopType != WorksharingLoopType::DistributeStaticLoop) {
4719- Constant *DistScheduleSchedType = ConstantInt::get (
4720- I32Type, static_cast <int >(omp::OMPScheduleType::OrderedDistribute));
4721- BuildInitCall (DistScheduleSchedType, Builder);
4722- }
47234715 Value *LowerBound = Builder.CreateLoad (IVTy, PLowerBound);
47244716 Value *InclusiveUpperBound = Builder.CreateLoad (IVTy, PUpperBound);
47254717 Value *TripCountMinusOne = Builder.CreateSub (InclusiveUpperBound, LowerBound);
@@ -4792,10 +4784,9 @@ static void applyParallelAccessesMetadata(CanonicalLoopInfo *CLI,
47924784OpenMPIRBuilder::InsertPointOrErrorTy
47934785OpenMPIRBuilder::applyStaticChunkedWorkshareLoop (
47944786 DebugLoc DL, CanonicalLoopInfo *CLI, InsertPointTy AllocaIP,
4795- bool NeedsBarrier, Value *ChunkSize, OMPScheduleType SchedType,
4796- Value *DistScheduleChunkSize, OMPScheduleType DistScheduleSchedType) {
4787+ bool NeedsBarrier, Value *ChunkSize, OMPScheduleType SchedType) {
47974788 assert (CLI->isValid () && " Requires a valid canonical loop" );
4798- assert (ChunkSize || DistScheduleChunkSize && " Chunk size is required" );
4789+ assert (ChunkSize && " Chunk size is required" );
47994790
48004791 LLVMContext &Ctx = CLI->getFunction ()->getContext ();
48014792 Value *IV = CLI->getIndVar ();
@@ -4817,7 +4808,7 @@ OpenMPIRBuilder::applyStaticChunkedWorkshareLoop(
48174808 LoopInfo &&LI = LIA.run (*F, FAM);
48184809 Loop *L = LI.getLoopFor (CLI->getHeader ());
48194810 SmallVector<Metadata *> LoopMDList;
4820- if (ChunkSize || DistScheduleChunkSize )
4811+ if (ChunkSize)
48214812 applyParallelAccessesMetadata (CLI, Ctx, L, LI, LoopMDList);
48224813 addLoopMetadata (CLI, LoopMDList);
48234814
@@ -4839,22 +4830,17 @@ OpenMPIRBuilder::applyStaticChunkedWorkshareLoop(
48394830 CLI->setLastIter (PLastIter);
48404831
48414832 // Set up the source location value for the OpenMP runtime.
4842- Builder.restoreIP (CLI->getPreheaderIP ());
4833+ Builder.restoreIP (CLI->getPreheaderIP ()); // -> sets insert point to omploop! Why?
48434834 Builder.SetCurrentDebugLocation (DL);
48444835
48454836 // TODO: Detect overflow in ubsan or max-out with current tripcount.
48464837 Value *CastedChunkSize = Builder.CreateZExtOrTrunc (
48474838 ChunkSize ? ChunkSize : Zero, InternalIVTy, " chunksize" );
4848- Value *CastestDistScheduleChunkSize = Builder.CreateZExtOrTrunc (
4849- DistScheduleChunkSize ? DistScheduleChunkSize : Zero, InternalIVTy,
4850- " distschedulechunksize" );
48514839 Value *CastedTripCount =
48524840 Builder.CreateZExt (OrigTripCount, InternalIVTy, " tripcount" );
48534841
48544842 Constant *SchedulingType =
48554843 ConstantInt::get (I32Type, static_cast <int >(SchedType));
4856- Constant *DistSchedulingType =
4857- ConstantInt::get (I32Type, static_cast <int >(DistScheduleSchedType));
48584844 Builder.CreateStore (Zero, PLowerBound);
48594845 Value *OrigUpperBound = Builder.CreateSub (CastedTripCount, One);
48604846 Builder.CreateStore (OrigUpperBound, PUpperBound);
@@ -4877,14 +4863,6 @@ OpenMPIRBuilder::applyStaticChunkedWorkshareLoop(
48774863 /* chunk=*/ ChunkSize});
48784864 };
48794865 BuildInitCall (SchedulingType, CastedChunkSize, Builder);
4880- if (DistScheduleSchedType != OMPScheduleType::None &&
4881- SchedType != OMPScheduleType::OrderedDistributeChunked &&
4882- SchedType != OMPScheduleType::OrderedDistribute) {
4883- // We want to emit a second init function call for the dist_schedule clause
4884- // to the Distribute construct. This should only be done however if a
4885- // Workshare Loop is nested within a Distribute Construct
4886- BuildInitCall (DistSchedulingType, CastestDistScheduleChunkSize, Builder);
4887- }
48884866
48894867 // Load values written by the "init" function.
48904868 Value *FirstChunkStart =
@@ -5208,35 +5186,27 @@ OpenMPIRBuilder::InsertPointOrErrorTy OpenMPIRBuilder::applyWorkshareLoop(
52085186 bool NeedsBarrier, omp::ScheduleKind SchedKind, Value *ChunkSize,
52095187 bool HasSimdModifier, bool HasMonotonicModifier,
52105188 bool HasNonmonotonicModifier, bool HasOrderedClause,
5211- WorksharingLoopType LoopType, bool HasDistSchedule,
5212- Value *DistScheduleChunkSize) {
5189+ WorksharingLoopType LoopType, bool HasDistSchedule) {
52135190 if (Config.isTargetDevice ())
52145191 return applyWorkshareLoopTarget (DL, CLI, AllocaIP, LoopType);
52155192 OMPScheduleType EffectiveScheduleType = computeOpenMPScheduleType (
52165193 SchedKind, ChunkSize, HasSimdModifier, HasMonotonicModifier,
5217- HasNonmonotonicModifier, HasOrderedClause, DistScheduleChunkSize );
5194+ HasNonmonotonicModifier, HasOrderedClause);
52185195
52195196 bool IsOrdered = (EffectiveScheduleType & OMPScheduleType::ModifierOrdered) ==
52205197 OMPScheduleType::ModifierOrdered;
5221- OMPScheduleType DistScheduleSchedType = OMPScheduleType::None;
5222- if (HasDistSchedule) {
5223- DistScheduleSchedType = DistScheduleChunkSize
5224- ? OMPScheduleType::OrderedDistributeChunked
5225- : OMPScheduleType::OrderedDistribute;
5226- }
52275198 switch (EffectiveScheduleType & ~OMPScheduleType::ModifierMask) {
52285199 case OMPScheduleType::BaseStatic:
52295200 case OMPScheduleType::BaseDistribute:
5230- assert (!ChunkSize || !DistScheduleChunkSize &&
5201+ assert (!ChunkSize &&
52315202 " No chunk size with static-chunked schedule" );
52325203 if (IsOrdered && !HasDistSchedule)
52335204 return applyDynamicWorkshareLoop (DL, CLI, AllocaIP, EffectiveScheduleType,
52345205 NeedsBarrier, ChunkSize);
52355206 // FIXME: Monotonicity ignored?
5236- if (DistScheduleChunkSize )
5207+ if (ChunkSize )
52375208 return applyStaticChunkedWorkshareLoop (
5238- DL, CLI, AllocaIP, NeedsBarrier, ChunkSize, EffectiveScheduleType,
5239- DistScheduleChunkSize, DistScheduleSchedType);
5209+ DL, CLI, AllocaIP, NeedsBarrier, ChunkSize, EffectiveScheduleType);
52405210 return applyStaticWorkshareLoop (DL, CLI, AllocaIP, LoopType, NeedsBarrier,
52415211 HasDistSchedule);
52425212
@@ -5247,8 +5217,7 @@ OpenMPIRBuilder::InsertPointOrErrorTy OpenMPIRBuilder::applyWorkshareLoop(
52475217 NeedsBarrier, ChunkSize);
52485218 // FIXME: Monotonicity ignored?
52495219 return applyStaticChunkedWorkshareLoop (
5250- DL, CLI, AllocaIP, NeedsBarrier, ChunkSize, EffectiveScheduleType,
5251- DistScheduleChunkSize, DistScheduleSchedType);
5220+ DL, CLI, AllocaIP, NeedsBarrier, ChunkSize, EffectiveScheduleType);
52525221
52535222 case OMPScheduleType::BaseRuntime:
52545223 case OMPScheduleType::BaseAuto:
0 commit comments