Skip to content

[NVPTX] Add Volta Atomic SequentiallyConsistent Load and Store Operations #98551

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 22 commits into from
Aug 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
9b965ba
[NVPTX] Support fence instruction
gonzalobg Jul 15, 2024
6616144
[NVPTX] Volta SequentiallyConsistent Load/Store Ops
gonzalobg Jul 9, 2024
c2711d1
[NVPTX] Align Memory Ordering enum with LLVM
gonzalobg Jul 11, 2024
8299d83
[NVPTX]: Fix typos
gonzalobg Jul 11, 2024
8066f50
[NVPTX] Cleanup SeqCst Load/Store
gonzalobg Jul 16, 2024
3f3fd6d
[NVPTX] Add vector load/store tests and refactor load/store tests
gonzalobg Jul 16, 2024
6b6ef48
[NVPTX] Cleanups
gonzalobg Jul 16, 2024
41fb361
[NVPTX] Update atomic volatile unordered test
gonzalobg Jul 25, 2024
4cc2825
[NVPTX] Update comment: now handling Unordered
gonzalobg Jul 25, 2024
932a902
[NVPTX] refactor NVPTX::Ordering to string/stream
gonzalobg Jul 30, 2024
5dc3e00
[NVPTX] Refactor OperationOrderings into anonymous namespace to avoid…
gonzalobg Jul 30, 2024
e36d7c4
[NVPTX] Cleanup error reporting
gonzalobg Jul 30, 2024
c9a5dd8
[NVPTX] Cleanup comments in tests
gonzalobg Jul 30, 2024
e727c76
[NVPTX] Refactor and clean up load,tryLoad,tryStore a bit
gonzalobg Jul 11, 2024
7ec8da6
[NVPTX] Simplify NVPTX::Ordering by not making it an enum class
gonzalobg Jul 31, 2024
8b3e450
[NVPTX] Move Ordering to string functions to utilities
gonzalobg Jul 31, 2024
2d8ab20
[NVPTX] Improve comments in load-store tests
gonzalobg Jul 31, 2024
3df9d66
[NVPTX] Refactor fence insertion for loads/stores
gonzalobg Jul 31, 2024
20be14b
[NVPTX] Refactor memory ordering
gonzalobg Aug 1, 2024
e865fc3
[NVPTX] Refactor and cleanups
gonzalobg Aug 1, 2024
8738385
[NVPTX] Switch to std::string
gonzalobg Aug 1, 2024
ba80e0f
[NVPTX] Ordering uses AtomicOrdering values directly
gonzalobg Aug 6, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 13 additions & 13 deletions llvm/lib/Target/NVPTX/MCTargetDesc/NVPTXInstPrinter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,14 @@
#include "MCTargetDesc/NVPTXInstPrinter.h"
#include "MCTargetDesc/NVPTXBaseInfo.h"
#include "NVPTX.h"
#include "NVPTXUtilities.h"
#include "llvm/MC/MCExpr.h"
#include "llvm/MC/MCInst.h"
#include "llvm/MC/MCInstrInfo.h"
#include "llvm/MC/MCSubtargetInfo.h"
#include "llvm/MC/MCSymbol.h"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/FormatVariadic.h"
#include "llvm/Support/FormattedStream.h"
#include <cctype>
using namespace llvm;
Expand Down Expand Up @@ -228,31 +230,29 @@ void NVPTXInstPrinter::printLdStCode(const MCInst *MI, int OpNum,
const MCOperand &MO = MI->getOperand(OpNum);
int Imm = (int) MO.getImm();
if (!strcmp(Modifier, "sem")) {
switch (Imm) {
case NVPTX::PTXLdStInstCode::NotAtomic:
auto Ordering = NVPTX::Ordering(Imm);
switch (Ordering) {
case NVPTX::Ordering::NotAtomic:
break;
case NVPTX::PTXLdStInstCode::Volatile:
case NVPTX::Ordering::Volatile:
O << ".volatile";
break;
case NVPTX::PTXLdStInstCode::Relaxed:
case NVPTX::Ordering::Relaxed:
O << ".relaxed.sys";
break;
case NVPTX::PTXLdStInstCode::Acquire:
case NVPTX::Ordering::Acquire:
O << ".acquire.sys";
break;
case NVPTX::PTXLdStInstCode::Release:
case NVPTX::Ordering::Release:
O << ".release.sys";
break;
case NVPTX::PTXLdStInstCode::RelaxedMMIO:
case NVPTX::Ordering::RelaxedMMIO:
O << ".mmio.relaxed.sys";
break;
default:
SmallString<256> Msg;
raw_svector_ostream OS(Msg);
OS << "NVPTX LdStCode Printer does not support \"" << Imm
<< "\" sem modifier.";
report_fatal_error(OS.str());
break;
report_fatal_error(formatv(
"NVPTX LdStCode Printer does not support \"{}\" sem modifier.",
OrderingToCString(Ordering)));
}
} else if (!strcmp(Modifier, "addsp")) {
switch (Imm) {
Expand Down
29 changes: 20 additions & 9 deletions llvm/lib/Target/NVPTX/NVPTX.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

#include "llvm/IR/PassManager.h"
#include "llvm/Pass.h"
#include "llvm/Support/AtomicOrdering.h"
#include "llvm/Support/CodeGen.h"

namespace llvm {
Expand Down Expand Up @@ -106,15 +107,25 @@ enum LoadStore {
isStoreShift = 6
};

namespace PTXLdStInstCode {
enum MemorySemantic {
NotAtomic = 0, // PTX calls these: "Weak"
Volatile = 1,
Relaxed = 2,
Acquire = 3,
Release = 4,
RelaxedMMIO = 5
// Extends LLVM AtomicOrdering with PTX Orderings:
using OrderingUnderlyingType = unsigned int;
enum Ordering : OrderingUnderlyingType {
NotAtomic = (OrderingUnderlyingType)
AtomicOrdering::NotAtomic, // PTX calls these: "Weak"
// Unordered = 1, // NVPTX maps LLVM Unorderd to Relaxed
Relaxed = (OrderingUnderlyingType)AtomicOrdering::Monotonic,
// Consume = 3, // Unimplemented in LLVM; NVPTX would map to "Acquire"
Acquire = (OrderingUnderlyingType)AtomicOrdering::Acquire,
Release = (OrderingUnderlyingType)AtomicOrdering::Release,
// AcquireRelease = 6, // TODO
SequentiallyConsistent =
(OrderingUnderlyingType)AtomicOrdering::SequentiallyConsistent,
Volatile = SequentiallyConsistent + 1,
RelaxedMMIO = Volatile + 1,
LAST = RelaxedMMIO
};

namespace PTXLdStInstCode {
enum AddressSpace {
GENERIC = 0,
GLOBAL = 1,
Expand All @@ -134,7 +145,7 @@ enum VecType {
V2 = 2,
V4 = 4
};
}
} // namespace PTXLdStInstCode

/// PTXCvtMode - Conversion code enumeration
namespace PTXCvtMode {
Expand Down
Loading