forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request rust-lang#14 from japaric/platform-intrinsics
NVPTX: platform intrinsics + tests
- Loading branch information
Showing
13 changed files
with
316 additions
and
53 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{ | ||
"intrinsic_prefix": "_", | ||
"llvm_prefix": "llvm.cuda.", | ||
"intrinsics": [ | ||
{ | ||
"intrinsic": "syncthreads", | ||
"width": ["0"], | ||
"llvm": "syncthreads", | ||
"ret": "V", | ||
"args": [] | ||
} | ||
] | ||
} |
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,7 @@ | ||
{ | ||
"platform": "nvptx", | ||
"number_info": { | ||
"signed": {} | ||
}, | ||
"width_info": {} | ||
} |
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,90 @@ | ||
{ | ||
"intrinsic_prefix": "_", | ||
"llvm_prefix": "llvm.nvvm.read.ptx.sreg.", | ||
"intrinsics": [ | ||
{ | ||
"intrinsic": "block_dim_x", | ||
"width": ["0"], | ||
"llvm": "ntid.x", | ||
"ret": "S32", | ||
"args": [] | ||
}, | ||
{ | ||
"intrinsic": "block_dim_y", | ||
"width": ["0"], | ||
"llvm": "ntid.y", | ||
"ret": "S32", | ||
"args": [] | ||
}, | ||
{ | ||
"intrinsic": "block_dim_z", | ||
"width": ["0"], | ||
"llvm": "ntid.z", | ||
"ret": "S32", | ||
"args": [] | ||
}, | ||
{ | ||
"intrinsic": "block_idx_x", | ||
"width": ["0"], | ||
"llvm": "ctaid.x", | ||
"ret": "S32", | ||
"args": [] | ||
}, | ||
{ | ||
"intrinsic": "block_idx_y", | ||
"width": ["0"], | ||
"llvm": "ctaid.y", | ||
"ret": "S32", | ||
"args": [] | ||
}, | ||
{ | ||
"intrinsic": "block_idx_z", | ||
"width": ["0"], | ||
"llvm": "ctaid.z", | ||
"ret": "S32", | ||
"args": [] | ||
}, | ||
{ | ||
"intrinsic": "grid_dim_x", | ||
"width": ["0"], | ||
"llvm": "nctaid.x", | ||
"ret": "S32", | ||
"args": [] | ||
}, | ||
{ | ||
"intrinsic": "grid_dim_y", | ||
"width": ["0"], | ||
"llvm": "nctaid.y", | ||
"ret": "S32", | ||
"args": [] | ||
}, | ||
{ | ||
"intrinsic": "grid_dim_z", | ||
"width": ["0"], | ||
"llvm": "nctaid.z", | ||
"ret": "S32", | ||
"args": [] | ||
}, | ||
{ | ||
"intrinsic": "thread_idx_x", | ||
"width": ["0"], | ||
"llvm": "tid.x", | ||
"ret": "S32", | ||
"args": [] | ||
}, | ||
{ | ||
"intrinsic": "thread_idx_y", | ||
"width": ["0"], | ||
"llvm": "tid.y", | ||
"ret": "S32", | ||
"args": [] | ||
}, | ||
{ | ||
"intrinsic": "thread_idx_z", | ||
"width": ["0"], | ||
"llvm": "tid.z", | ||
"ret": "S32", | ||
"args": [] | ||
} | ||
] | ||
} |
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,92 @@ | ||
// Copyright 2015 The Rust Project Developers. See the COPYRIGHT | ||
// file at the top-level directory of this distribution and at | ||
// http://rust-lang.org/COPYRIGHT. | ||
// | ||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or | ||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license | ||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your | ||
// option. This file may not be copied, modified, or distributed | ||
// except according to those terms. | ||
|
||
// DO NOT EDIT: autogenerated by etc/platform-intrinsics/generator.py | ||
// ignore-tidy-linelength | ||
|
||
#![allow(unused_imports)] | ||
|
||
use {Intrinsic, Type}; | ||
use IntrinsicDef::Named; | ||
|
||
// The default inlining settings trigger a pathological behaviour in | ||
// LLVM, which causes makes compilation very slow. See #28273. | ||
#[inline(never)] | ||
pub fn find(name: &str) -> Option<Intrinsic> { | ||
if !name.starts_with("nvptx") { return None } | ||
Some(match &name["nvptx".len()..] { | ||
"_syncthreads" => Intrinsic { | ||
inputs: { static INPUTS: [&'static Type; 0] = []; &INPUTS }, | ||
output: &::VOID, | ||
definition: Named("llvm.cuda.syncthreads") | ||
}, | ||
"_block_dim_x" => Intrinsic { | ||
inputs: { static INPUTS: [&'static Type; 0] = []; &INPUTS }, | ||
output: &::I32, | ||
definition: Named("llvm.nvvm.read.ptx.sreg.ntid.x") | ||
}, | ||
"_block_dim_y" => Intrinsic { | ||
inputs: { static INPUTS: [&'static Type; 0] = []; &INPUTS }, | ||
output: &::I32, | ||
definition: Named("llvm.nvvm.read.ptx.sreg.ntid.y") | ||
}, | ||
"_block_dim_z" => Intrinsic { | ||
inputs: { static INPUTS: [&'static Type; 0] = []; &INPUTS }, | ||
output: &::I32, | ||
definition: Named("llvm.nvvm.read.ptx.sreg.ntid.z") | ||
}, | ||
"_block_idx_x" => Intrinsic { | ||
inputs: { static INPUTS: [&'static Type; 0] = []; &INPUTS }, | ||
output: &::I32, | ||
definition: Named("llvm.nvvm.read.ptx.sreg.ctaid.x") | ||
}, | ||
"_block_idx_y" => Intrinsic { | ||
inputs: { static INPUTS: [&'static Type; 0] = []; &INPUTS }, | ||
output: &::I32, | ||
definition: Named("llvm.nvvm.read.ptx.sreg.ctaid.y") | ||
}, | ||
"_block_idx_z" => Intrinsic { | ||
inputs: { static INPUTS: [&'static Type; 0] = []; &INPUTS }, | ||
output: &::I32, | ||
definition: Named("llvm.nvvm.read.ptx.sreg.ctaid.z") | ||
}, | ||
"_grid_dim_x" => Intrinsic { | ||
inputs: { static INPUTS: [&'static Type; 0] = []; &INPUTS }, | ||
output: &::I32, | ||
definition: Named("llvm.nvvm.read.ptx.sreg.nctaid.x") | ||
}, | ||
"_grid_dim_y" => Intrinsic { | ||
inputs: { static INPUTS: [&'static Type; 0] = []; &INPUTS }, | ||
output: &::I32, | ||
definition: Named("llvm.nvvm.read.ptx.sreg.nctaid.y") | ||
}, | ||
"_grid_dim_z" => Intrinsic { | ||
inputs: { static INPUTS: [&'static Type; 0] = []; &INPUTS }, | ||
output: &::I32, | ||
definition: Named("llvm.nvvm.read.ptx.sreg.nctaid.z") | ||
}, | ||
"_thread_idx_x" => Intrinsic { | ||
inputs: { static INPUTS: [&'static Type; 0] = []; &INPUTS }, | ||
output: &::I32, | ||
definition: Named("llvm.nvvm.read.ptx.sreg.tid.x") | ||
}, | ||
"_thread_idx_y" => Intrinsic { | ||
inputs: { static INPUTS: [&'static Type; 0] = []; &INPUTS }, | ||
output: &::I32, | ||
definition: Named("llvm.nvvm.read.ptx.sreg.tid.y") | ||
}, | ||
"_thread_idx_z" => Intrinsic { | ||
inputs: { static INPUTS: [&'static Type; 0] = []; &INPUTS }, | ||
output: &::I32, | ||
definition: Named("llvm.nvvm.read.ptx.sreg.tid.z") | ||
}, | ||
_ => return None, | ||
}) | ||
} |
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,32 @@ | ||
-include ../tools.mk | ||
|
||
NVPTX = nvptx-unknown-unknown | ||
NVPTX64 = nvptx64-unknown-unknown | ||
|
||
all: smoke syncthreads thread_idx | ||
|
||
smoke: | ||
$(RUSTC) --target $(NVPTX) --emit=asm $@.rs | ||
grep '\.address_size *32' $(TMPDIR)/$@.s | ||
$(RUSTC) --target $(NVPTX64) --emit=asm $@.rs | ||
grep '\.address_size *64' $(TMPDIR)/$@.s | ||
|
||
syncthreads: | ||
$(RUSTC) --target $(NVPTX) --emit=llvm-ir $@.rs | ||
grep 'call.*syncthreads' $(TMPDIR)/$@.ll | ||
$(RUSTC) --target $(NVPTX64) --emit=llvm-ir $@.rs | ||
grep 'call.*syncthreads' $(TMPDIR)/$@.ll | ||
$(RUSTC) --target $(NVPTX) --emit=asm $@.rs | ||
grep 'bar\.sync' $(TMPDIR)/$@.s | ||
$(RUSTC) --target $(NVPTX64) --emit=asm $@.rs | ||
grep 'bar\.sync' $(TMPDIR)/$@.s | ||
|
||
thread_idx: | ||
$(RUSTC) --target $(NVPTX) --emit=llvm-ir $@.rs | ||
grep 'call.*tid\.x' $(TMPDIR)/$@.ll | ||
$(RUSTC) --target $(NVPTX64) --emit=llvm-ir $@.rs | ||
grep 'call.*tid\.x' $(TMPDIR)/$@.ll | ||
$(RUSTC) --target $(NVPTX) --emit=asm $@.rs | ||
grep '%tid\.x' $(TMPDIR)/$@.s | ||
$(RUSTC) --target $(NVPTX64) --emit=asm $@.rs | ||
grep '%tid\.x' $(TMPDIR)/$@.s |
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,13 @@ | ||
// Copyright 2016 The Rust Project Developers. See the COPYRIGHT | ||
// file at the top-level directory of this distribution and at | ||
// http://rust-lang.org/COPYRIGHT. | ||
// | ||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or | ||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license | ||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your | ||
// option. This file may not be copied, modified, or distributed | ||
// except according to those terms. | ||
|
||
#![feature(no_core)] | ||
|
||
#![no_core] |
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,33 @@ | ||
// Copyright 2016 The Rust Project Developers. See the COPYRIGHT | ||
// file at the top-level directory of this distribution and at | ||
// http://rust-lang.org/COPYRIGHT. | ||
// | ||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or | ||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license | ||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your | ||
// option. This file may not be copied, modified, or distributed | ||
// except according to those terms. | ||
|
||
#![feature(lang_items)] | ||
#![feature(no_core)] | ||
#![feature(platform_intrinsics)] | ||
|
||
#![no_core] | ||
|
||
#![allow(dead_code)] | ||
|
||
extern "platform-intrinsic" { | ||
fn nvptx_syncthreads(); | ||
} | ||
|
||
fn syncthreads() { | ||
unsafe { | ||
nvptx_syncthreads(); | ||
} | ||
} | ||
|
||
#[lang = "copy"] | ||
trait Copy {} | ||
|
||
#[lang = "sized"] | ||
trait Sized {} |
Oops, something went wrong.