Skip to content

Commit

Permalink
[NVPTX] Add Volta Load/Store Atomics (.relaxed, .acquire, .release) a…
Browse files Browse the repository at this point in the history
…nd Volatile (.mmio/.volatile) support (llvm#98022)

This PR adds initial support for some of Volta's (sm_70) load/store
atomic and volatile/MMIO operations, hopefully without breaking any
preexisting code. Only relaxed, acquire, and release operations w/
volatile are handled.

This PR does not aim to add support for any of the following:
- syncscope support
- read atomic ops to const, param, grid param
- local memory atomics
- sequentially consistent atomics
- atomicrmw 
- ...
  • Loading branch information
gonzalobg authored Jul 15, 2024
1 parent 8659c91 commit 2da30f8
Show file tree
Hide file tree
Showing 7 changed files with 1,848 additions and 157 deletions.
28 changes: 26 additions & 2 deletions llvm/lib/Target/NVPTX/MCTargetDesc/NVPTXInstPrinter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -227,9 +227,33 @@ void NVPTXInstPrinter::printLdStCode(const MCInst *MI, int OpNum,
if (Modifier) {
const MCOperand &MO = MI->getOperand(OpNum);
int Imm = (int) MO.getImm();
if (!strcmp(Modifier, "volatile")) {
if (Imm)
if (!strcmp(Modifier, "sem")) {
switch (Imm) {
case NVPTX::PTXLdStInstCode::NotAtomic:
break;
case NVPTX::PTXLdStInstCode::Volatile:
O << ".volatile";
break;
case NVPTX::PTXLdStInstCode::Relaxed:
O << ".relaxed.sys";
break;
case NVPTX::PTXLdStInstCode::Acquire:
O << ".acquire.sys";
break;
case NVPTX::PTXLdStInstCode::Release:
O << ".release.sys";
break;
case NVPTX::PTXLdStInstCode::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;
}
} else if (!strcmp(Modifier, "addsp")) {
switch (Imm) {
case NVPTX::PTXLdStInstCode::GLOBAL:
Expand Down
8 changes: 8 additions & 0 deletions llvm/lib/Target/NVPTX/NVPTX.h
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,14 @@ enum LoadStore {
};

namespace PTXLdStInstCode {
enum MemorySemantic {
NotAtomic = 0, // PTX calls these: "Weak"
Volatile = 1,
Relaxed = 2,
Acquire = 3,
Release = 4,
RelaxedMMIO = 5
};
enum AddressSpace {
GENERIC = 0,
GLOBAL = 1,
Expand Down
Loading

0 comments on commit 2da30f8

Please sign in to comment.