@@ -1574,11 +1574,6 @@ enum CopyAction : unsigned {
1574
1574
RemoteLaneToThread,
1575
1575
// ThreadCopy: Make a copy of a Reduce list on the thread's stack.
1576
1576
ThreadCopy,
1577
- // ThreadToScratchpad: Copy a team-reduced array to the scratchpad.
1578
- ThreadToScratchpad,
1579
- // ScratchpadToThread: Copy from a scratchpad array in global memory
1580
- // containing team-reduced data to a thread's stack.
1581
- ScratchpadToThread,
1582
1577
};
1583
1578
} // namespace
1584
1579
@@ -1600,13 +1595,10 @@ static void emitReductionListCopy(
1600
1595
CGBuilderTy &Bld = CGF.Builder ;
1601
1596
1602
1597
llvm::Value *RemoteLaneOffset = CopyOptions.RemoteLaneOffset ;
1603
- llvm::Value *ScratchpadIndex = CopyOptions.ScratchpadIndex ;
1604
- llvm::Value *ScratchpadWidth = CopyOptions.ScratchpadWidth ;
1605
1598
1606
1599
// Iterates, element-by-element, through the source Reduce list and
1607
1600
// make a copy.
1608
1601
unsigned Idx = 0 ;
1609
- unsigned Size = Privates.size ();
1610
1602
for (const Expr *Private : Privates) {
1611
1603
Address SrcElementAddr = Address::invalid ();
1612
1604
Address DestElementAddr = Address::invalid ();
@@ -1616,10 +1608,6 @@ static void emitReductionListCopy(
1616
1608
// Set to true to update the pointer in the dest Reduce list to a
1617
1609
// newly created element.
1618
1610
bool UpdateDestListPtr = false ;
1619
- // Increment the src or dest pointer to the scratchpad, for each
1620
- // new element.
1621
- bool IncrScratchpadSrc = false ;
1622
- bool IncrScratchpadDest = false ;
1623
1611
QualType PrivatePtrType = C.getPointerType (Private->getType ());
1624
1612
llvm::Type *PrivateLlvmPtrType = CGF.ConvertType (PrivatePtrType);
1625
1613
@@ -1655,49 +1643,6 @@ static void emitReductionListCopy(
1655
1643
PrivatePtrType->castAs <PointerType>());
1656
1644
break ;
1657
1645
}
1658
- case ThreadToScratchpad: {
1659
- // Step 1.1: Get the address for the src element in the Reduce list.
1660
- Address SrcElementPtrAddr = Bld.CreateConstArrayGEP (SrcBase, Idx);
1661
- SrcElementAddr = CGF.EmitLoadOfPointer (
1662
- SrcElementPtrAddr.withElementType (PrivateLlvmPtrType),
1663
- PrivatePtrType->castAs <PointerType>());
1664
-
1665
- // Step 1.2: Get the address for dest element:
1666
- // address = base + index * ElementSizeInChars.
1667
- llvm::Value *ElementSizeInChars = CGF.getTypeSize (Private->getType ());
1668
- llvm::Value *CurrentOffset =
1669
- Bld.CreateNUWMul (ElementSizeInChars, ScratchpadIndex);
1670
- llvm::Value *ScratchPadElemAbsolutePtrVal =
1671
- Bld.CreateNUWAdd (DestBase.getPointer (), CurrentOffset);
1672
- ScratchPadElemAbsolutePtrVal =
1673
- Bld.CreateIntToPtr (ScratchPadElemAbsolutePtrVal, CGF.VoidPtrTy );
1674
- DestElementAddr = Address (ScratchPadElemAbsolutePtrVal, CGF.Int8Ty ,
1675
- C.getTypeAlignInChars (Private->getType ()));
1676
- IncrScratchpadDest = true ;
1677
- break ;
1678
- }
1679
- case ScratchpadToThread: {
1680
- // Step 1.1: Get the address for the src element in the scratchpad.
1681
- // address = base + index * ElementSizeInChars.
1682
- llvm::Value *ElementSizeInChars = CGF.getTypeSize (Private->getType ());
1683
- llvm::Value *CurrentOffset =
1684
- Bld.CreateNUWMul (ElementSizeInChars, ScratchpadIndex);
1685
- llvm::Value *ScratchPadElemAbsolutePtrVal =
1686
- Bld.CreateNUWAdd (SrcBase.getPointer (), CurrentOffset);
1687
- ScratchPadElemAbsolutePtrVal =
1688
- Bld.CreateIntToPtr (ScratchPadElemAbsolutePtrVal, CGF.VoidPtrTy );
1689
- SrcElementAddr = Address (ScratchPadElemAbsolutePtrVal, CGF.Int8Ty ,
1690
- C.getTypeAlignInChars (Private->getType ()));
1691
- IncrScratchpadSrc = true ;
1692
-
1693
- // Step 1.2: Create a temporary to store the element in the destination
1694
- // Reduce list.
1695
- DestElementPtrAddr = Bld.CreateConstArrayGEP (DestBase, Idx);
1696
- DestElementAddr =
1697
- CGF.CreateMemTemp (Private->getType (), " .omp.reduction.element" );
1698
- UpdateDestListPtr = true ;
1699
- break ;
1700
- }
1701
1646
}
1702
1647
1703
1648
// Regardless of src and dest of copy, we emit the load of src
@@ -1755,39 +1700,6 @@ static void emitReductionListCopy(
1755
1700
C.VoidPtrTy );
1756
1701
}
1757
1702
1758
- // Step 4.1: Increment SrcBase/DestBase so that it points to the starting
1759
- // address of the next element in scratchpad memory, unless we're currently
1760
- // processing the last one. Memory alignment is also taken care of here.
1761
- if ((IncrScratchpadDest || IncrScratchpadSrc) && (Idx + 1 < Size)) {
1762
- // FIXME: This code doesn't make any sense, it's trying to perform
1763
- // integer arithmetic on pointers.
1764
- llvm::Value *ScratchpadBasePtr =
1765
- IncrScratchpadDest ? DestBase.getPointer () : SrcBase.getPointer ();
1766
- llvm::Value *ElementSizeInChars = CGF.getTypeSize (Private->getType ());
1767
- ScratchpadBasePtr = Bld.CreateNUWAdd (
1768
- ScratchpadBasePtr,
1769
- Bld.CreateNUWMul (ScratchpadWidth, ElementSizeInChars));
1770
-
1771
- // Take care of global memory alignment for performance
1772
- ScratchpadBasePtr = Bld.CreateNUWSub (
1773
- ScratchpadBasePtr, llvm::ConstantInt::get (CGM.SizeTy , 1 ));
1774
- ScratchpadBasePtr = Bld.CreateUDiv (
1775
- ScratchpadBasePtr,
1776
- llvm::ConstantInt::get (CGM.SizeTy , GlobalMemoryAlignment));
1777
- ScratchpadBasePtr = Bld.CreateNUWAdd (
1778
- ScratchpadBasePtr, llvm::ConstantInt::get (CGM.SizeTy , 1 ));
1779
- ScratchpadBasePtr = Bld.CreateNUWMul (
1780
- ScratchpadBasePtr,
1781
- llvm::ConstantInt::get (CGM.SizeTy , GlobalMemoryAlignment));
1782
-
1783
- if (IncrScratchpadDest)
1784
- DestBase =
1785
- Address (ScratchpadBasePtr, CGF.VoidPtrTy , CGF.getPointerAlign ());
1786
- else /* IncrScratchpadSrc = true */
1787
- SrcBase =
1788
- Address (ScratchpadBasePtr, CGF.VoidPtrTy , CGF.getPointerAlign ());
1789
- }
1790
-
1791
1703
++Idx;
1792
1704
}
1793
1705
}
0 commit comments