Skip to content

Commit

Permalink
add tests for NVPTX backend
Browse files Browse the repository at this point in the history
  • Loading branch information
Jorge Aparicio committed Jul 10, 2016
1 parent 9487913 commit 43cfa4b
Show file tree
Hide file tree
Showing 4 changed files with 83 additions and 0 deletions.
32 changes: 32 additions & 0 deletions src/test/run-make/nvptx/Makefile
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
5 changes: 5 additions & 0 deletions src/test/run-make/nvptx/smoke.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#![feature(lang_items)]
#![feature(no_core)]
#![feature(platform_intrinsics)]

#![no_core]
23 changes: 23 additions & 0 deletions src/test/run-make/nvptx/syncthreads.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#![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 {}
23 changes: 23 additions & 0 deletions src/test/run-make/nvptx/thread_idx.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#![feature(lang_items)]
#![feature(no_core)]
#![feature(platform_intrinsics)]

#![no_core]

#![allow(dead_code)]

extern "platform-intrinsic" {
fn nvptx_thread_idx_x() -> i32;
}

fn thread_idx() -> i32 {
unsafe {
nvptx_thread_idx_x()
}
}

#[lang = "copy"]
trait Copy {}

#[lang = "sized"]
trait Sized {}

0 comments on commit 43cfa4b

Please sign in to comment.