-
Notifications
You must be signed in to change notification settings - Fork 13.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
23 changed files
with
328 additions
and
141 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#![feature(core_intrinsics)] | ||
#![no_std] | ||
|
||
#[panic_handler] | ||
unsafe fn breakpoint_panic_handler(_: &::core::panic::PanicInfo) -> ! { | ||
core::intrinsics::breakpoint(); | ||
core::hint::unreachable_unchecked(); | ||
} |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
// assembly-output: ptx-linker | ||
// compile-flags: --crate-type cdylib | ||
// only-nvptx64 | ||
|
||
#![no_std] | ||
|
||
// aux-build: breakpoint-panic-handler.rs | ||
extern crate breakpoint_panic_handler; | ||
|
||
// Verify default target arch with ptx-linker. | ||
// CHECK: .target sm_30 | ||
// CHECK: .address_size 64 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
// assembly-output: emit-asm | ||
// compile-flags: --crate-type rlib | ||
// only-nvptx64 | ||
|
||
#![no_std] | ||
|
||
// Verify default arch without ptx-linker involved. | ||
// CHECK: .target sm_30 | ||
// CHECK: .address_size 64 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
// assembly-output: ptx-linker | ||
// compile-flags: --crate-type cdylib -C link-arg=--arch=sm_60 | ||
// only-nvptx64 | ||
|
||
#![no_std] | ||
|
||
// aux-build: breakpoint-panic-handler.rs | ||
extern crate breakpoint_panic_handler; | ||
|
||
// Verify target arch override via `link-arg`. | ||
// CHECK: .target sm_60 | ||
// CHECK: .address_size 64 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
// assembly-output: ptx-linker | ||
// compile-flags: --crate-type cdylib -C target-cpu=sm_50 | ||
// only-nvptx64 | ||
|
||
#![no_std] | ||
|
||
// aux-build: breakpoint-panic-handler.rs | ||
extern crate breakpoint_panic_handler; | ||
|
||
// Verify target arch override via `target-cpu`. | ||
// CHECK: .target sm_50 | ||
// CHECK: .address_size 64 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
// assembly-output: ptx-linker | ||
// compile-flags: --crate-type cdylib | ||
// only-nvptx64 | ||
|
||
#![feature(abi_ptx, core_intrinsics)] | ||
#![no_std] | ||
|
||
use core::intrinsics::*; | ||
|
||
// aux-build: breakpoint-panic-handler.rs | ||
extern crate breakpoint_panic_handler; | ||
|
||
// Currently, LLVM NVPTX backend can only emit atomic instructions with | ||
// `relaxed` (PTX default) ordering. But it's also useful to make sure | ||
// the backend won't fail with other orders. Apparently, the backend | ||
// doesn't support fences as well. As a workaround `llvm.nvvm.membar.*` | ||
// could work, and perhaps on the long run, all the atomic operations | ||
// should rather be provided by `core::arch::nvptx`. | ||
|
||
// Also, PTX ISA doesn't have atomic `load`, `store` and `nand`. | ||
|
||
// FIXME(denzp): add tests for `core::sync::atomic::*`. | ||
|
||
#[no_mangle] | ||
pub unsafe extern "ptx-kernel" fn atomics_kernel(a: *mut u32) { | ||
// CHECK: atom.global.and.b32 %{{r[0-9]+}}, [%{{rd[0-9]+}}], 1; | ||
// CHECK: atom.global.and.b32 %{{r[0-9]+}}, [%{{rd[0-9]+}}], 1; | ||
atomic_and(a, 1); | ||
atomic_and_relaxed(a, 1); | ||
|
||
// CHECK: atom.global.cas.b32 %{{r[0-9]+}}, [%{{rd[0-9]+}}], 1, 2; | ||
// CHECK: atom.global.cas.b32 %{{r[0-9]+}}, [%{{rd[0-9]+}}], 1, 2; | ||
atomic_cxchg(a, 1, 2); | ||
atomic_cxchg_relaxed(a, 1, 2); | ||
|
||
// CHECK: atom.global.max.s32 %{{r[0-9]+}}, [%{{rd[0-9]+}}], 1; | ||
// CHECK: atom.global.max.s32 %{{r[0-9]+}}, [%{{rd[0-9]+}}], 1; | ||
atomic_max(a, 1); | ||
atomic_max_relaxed(a, 1); | ||
|
||
// CHECK: atom.global.min.s32 %{{r[0-9]+}}, [%{{rd[0-9]+}}], 1; | ||
// CHECK: atom.global.min.s32 %{{r[0-9]+}}, [%{{rd[0-9]+}}], 1; | ||
atomic_min(a, 1); | ||
atomic_min_relaxed(a, 1); | ||
|
||
// CHECK: atom.global.or.b32 %{{r[0-9]+}}, [%{{rd[0-9]+}}], 1; | ||
// CHECK: atom.global.or.b32 %{{r[0-9]+}}, [%{{rd[0-9]+}}], 1; | ||
atomic_or(a, 1); | ||
atomic_or_relaxed(a, 1); | ||
|
||
// CHECK: atom.global.max.u32 %{{r[0-9]+}}, [%{{rd[0-9]+}}], 1; | ||
// CHECK: atom.global.max.u32 %{{r[0-9]+}}, [%{{rd[0-9]+}}], 1; | ||
atomic_umax(a, 1); | ||
atomic_umax_relaxed(a, 1); | ||
|
||
// CHECK: atom.global.min.u32 %{{r[0-9]+}}, [%{{rd[0-9]+}}], 1; | ||
// CHECK: atom.global.min.u32 %{{r[0-9]+}}, [%{{rd[0-9]+}}], 1; | ||
atomic_umin(a, 1); | ||
atomic_umin_relaxed(a, 1); | ||
|
||
// CHECK: atom.global.add.u32 %{{r[0-9]+}}, [%{{rd[0-9]+}}], 1; | ||
// CHECK: atom.global.add.u32 %{{r[0-9]+}}, [%{{rd[0-9]+}}], 1; | ||
atomic_xadd(a, 1); | ||
atomic_xadd_relaxed(a, 1); | ||
|
||
// CHECK: atom.global.exch.b32 %{{r[0-9]+}}, [%{{rd[0-9]+}}], 1; | ||
// CHECK: atom.global.exch.b32 %{{r[0-9]+}}, [%{{rd[0-9]+}}], 1; | ||
atomic_xchg(a, 1); | ||
atomic_xchg_relaxed(a, 1); | ||
|
||
// CHECK: atom.global.xor.b32 %{{r[0-9]+}}, [%{{rd[0-9]+}}], 1; | ||
// CHECK: atom.global.xor.b32 %{{r[0-9]+}}, [%{{rd[0-9]+}}], 1; | ||
atomic_xor(a, 1); | ||
atomic_xor_relaxed(a, 1); | ||
|
||
// CHECK: mov.u32 %[[sub_0_arg:r[0-9]+]], 100; | ||
// CHECK: neg.s32 temp, %[[sub_0_arg]]; | ||
// CHECK: atom.global.add.u32 %{{r[0-9]+}}, [%{{rd[0-9]+}}], temp; | ||
atomic_xsub(a, 100); | ||
|
||
// CHECK: mov.u32 %[[sub_1_arg:r[0-9]+]], 200; | ||
// CHECK: neg.s32 temp, %[[sub_1_arg]]; | ||
// CHECK: atom.global.add.u32 %{{r[0-9]+}}, [%{{rd[0-9]+}}], temp; | ||
atomic_xsub_relaxed(a, 200); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
// assembly-output: ptx-linker | ||
// compile-flags: --crate-type cdylib | ||
// only-nvptx64 | ||
|
||
#![feature(abi_ptx)] | ||
#![no_std] | ||
|
||
// aux-build: breakpoint-panic-handler.rs | ||
extern crate breakpoint_panic_handler; | ||
|
||
// aux-build: non-inline-dependency.rs | ||
extern crate non_inline_dependency as dep; | ||
|
||
// Verify that no extra function declarations are present. | ||
// CHECK-NOT: .func | ||
|
||
// CHECK: .visible .entry top_kernel( | ||
#[no_mangle] | ||
pub unsafe extern "ptx-kernel" fn top_kernel(a: *const u32, b: *mut u32) { | ||
// CHECK: add.s32 %{{r[0-9]+}}, %{{r[0-9]+}}, 5; | ||
*b = *a + 5; | ||
} | ||
|
||
// Verify that no extra function definitions are here. | ||
// CHECK-NOT: .func | ||
// CHECK-NOT: .entry | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
// assembly-output: ptx-linker | ||
// compile-flags: --crate-type bin | ||
// only-nvptx64 | ||
|
||
#![feature(abi_ptx)] | ||
#![no_main] | ||
#![no_std] | ||
|
||
// aux-build: breakpoint-panic-handler.rs | ||
extern crate breakpoint_panic_handler; | ||
|
||
// aux-build: non-inline-dependency.rs | ||
extern crate non_inline_dependency as dep; | ||
|
||
// Make sure declarations are there. | ||
// CHECK: .func (.param .b32 func_retval0) wrapping_external_fn | ||
// CHECK: .func (.param .b32 func_retval0) panicking_external_fn | ||
|
||
// CHECK-LABEL: .visible .entry top_kernel( | ||
#[no_mangle] | ||
pub unsafe extern "ptx-kernel" fn top_kernel(a: *const u32, b: *mut u32) { | ||
// CHECK: call.uni (retval0), | ||
// CHECK-NEXT: wrapping_external_fn | ||
// CHECK: ld.param.b32 %[[LHS:r[0-9]+]], [retval0+0]; | ||
let lhs = dep::wrapping_external_fn(*a); | ||
|
||
// CHECK: call.uni (retval0), | ||
// CHECK-NEXT: panicking_external_fn | ||
// CHECK: ld.param.b32 %[[RHS:r[0-9]+]], [retval0+0]; | ||
let rhs = dep::panicking_external_fn(*a); | ||
|
||
// CHECK: add.s32 %[[RES:r[0-9]+]], %[[RHS]], %[[LHS]]; | ||
// CHECK: st.global.u32 [%{{rd[0-9]+}}], %[[RES]]; | ||
*b = lhs + rhs; | ||
} | ||
|
||
// Verify that external function bodies are available. | ||
// CHECK: .func (.param .b32 func_retval0) wrapping_external_fn | ||
// CHECK: .func (.param .b32 func_retval0) panicking_external_fn |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
// assembly-output: ptx-linker | ||
// compile-flags: --crate-type cdylib | ||
// only-nvptx64 | ||
|
||
#![feature(abi_ptx)] | ||
#![no_std] | ||
|
||
// aux-build: breakpoint-panic-handler.rs | ||
extern crate breakpoint_panic_handler; | ||
|
||
// aux-build: non-inline-dependency.rs | ||
extern crate non_inline_dependency as dep; | ||
|
||
// Make sure declarations are there. | ||
// CHECK: .func (.param .b32 func_retval0) wrapping_external_fn | ||
// CHECK: .func (.param .b32 func_retval0) panicking_external_fn | ||
|
||
// CHECK-LABEL: .visible .entry top_kernel( | ||
#[no_mangle] | ||
pub unsafe extern "ptx-kernel" fn top_kernel(a: *const u32, b: *mut u32) { | ||
// CHECK: call.uni (retval0), | ||
// CHECK-NEXT: wrapping_external_fn | ||
// CHECK: ld.param.b32 %[[LHS:r[0-9]+]], [retval0+0]; | ||
let lhs = dep::wrapping_external_fn(*a); | ||
|
||
// CHECK: call.uni (retval0), | ||
// CHECK-NEXT: panicking_external_fn | ||
// CHECK: ld.param.b32 %[[RHS:r[0-9]+]], [retval0+0]; | ||
let rhs = dep::panicking_external_fn(*a); | ||
|
||
// CHECK: add.s32 %[[RES:r[0-9]+]], %[[RHS]], %[[LHS]]; | ||
// CHECK: st.global.u32 [%{{rd[0-9]+}}], %[[RES]]; | ||
*b = lhs + rhs; | ||
} | ||
|
||
// Verify that external function bodies are available. | ||
// CHECK: .func (.param .b32 func_retval0) wrapping_external_fn | ||
// CHECK: .func (.param .b32 func_retval0) panicking_external_fn |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.