-
Notifications
You must be signed in to change notification settings - Fork 0
/
nocore.rs
51 lines (40 loc) · 880 Bytes
/
nocore.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#![crate_type = "lib"]
#![feature(abi_ptx)]
#![feature(link_llvm_intrinsics)]
#![feature(naked_functions)]
#![feature(lang_items)]
#![feature(no_core)]
#![no_core]
#[lang = "sized"]
trait Sized {}
#[lang = "copy"]
trait Copy {}
#[allow(improper_ctypes)]
extern "C" {
#[link_name = "llvm.nvvm.barrier0"]
fn syncthreads() -> ();
#[link_name = "llvm.nvvm.read.ptx.sreg.tid.x"]
fn thread_idx_x() -> i32;
}
#[inline]
pub unsafe fn _syncthreads() -> () {
syncthreads()
}
#[inline]
pub unsafe fn _thread_idx_x() -> i32 {
thread_idx_x()
}
#[no_mangle]
pub unsafe extern "ptx-kernel" fn test_syncthreads() {
_syncthreads();
}
#[no_mangle]
pub unsafe extern "ptx-kernel" fn foo() {
let p: *mut i32 = 4096 as *mut i32;
*p = _thread_idx_x();
}
#[no_mangle]
pub unsafe extern "ptx-kernel" fn bar() {
let p: *mut i32 = 4096 as *mut i32;
*p = _thread_idx_x();
}