forked from chapuni/clang
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
PTX: Add PTX intrinsics as builtins and add ptx32 and ptx64 as valid …
…architectures for triples, e.g. ptx32-unknown-unknown git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@129870 91177308-0d34-0410-b5e6-96231b3b80d8
- Loading branch information
1 parent
cbec959
commit 285dc65
Showing
4 changed files
with
258 additions
and
0 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,62 @@ | ||
//===--- BuiltinsPTX.def - PTX Builtin function database ----*- C++ -*-===// | ||
// | ||
// The LLVM Compiler Infrastructure | ||
// | ||
// This file is distributed under the University of Illinois Open Source | ||
// License. See LICENSE.TXT for details. | ||
// | ||
//===----------------------------------------------------------------------===// | ||
// | ||
// This file defines the PTX-specific builtin function database. Users of | ||
// this file must define the BUILTIN macro to make use of this information. | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
// The format of this database matches clang/Basic/Builtins.def. | ||
|
||
BUILTIN(__builtin_ptx_read_tid_x, "i", "nc") | ||
BUILTIN(__builtin_ptx_read_tid_y, "i", "nc") | ||
BUILTIN(__builtin_ptx_read_tid_z, "i", "nc") | ||
BUILTIN(__builtin_ptx_read_tid_w, "i", "nc") | ||
|
||
BUILTIN(__builtin_ptx_read_ntid_x, "i", "nc") | ||
BUILTIN(__builtin_ptx_read_ntid_y, "i", "nc") | ||
BUILTIN(__builtin_ptx_read_ntid_z, "i", "nc") | ||
BUILTIN(__builtin_ptx_read_ntid_w, "i", "nc") | ||
|
||
BUILTIN(__builtin_ptx_read_ctaid_x, "i", "nc") | ||
BUILTIN(__builtin_ptx_read_ctaid_y, "i", "nc") | ||
BUILTIN(__builtin_ptx_read_ctaid_z, "i", "nc") | ||
BUILTIN(__builtin_ptx_read_ctaid_w, "i", "nc") | ||
|
||
BUILTIN(__builtin_ptx_read_nctaid_x, "i", "nc") | ||
BUILTIN(__builtin_ptx_read_nctaid_y, "i", "nc") | ||
BUILTIN(__builtin_ptx_read_nctaid_z, "i", "nc") | ||
BUILTIN(__builtin_ptx_read_nctaid_w, "i", "nc") | ||
|
||
BUILTIN(__builtin_ptx_read_laneid, "i", "nc") | ||
BUILTIN(__builtin_ptx_read_warpid, "i", "nc") | ||
BUILTIN(__builtin_ptx_read_nwarpid, "i", "nc") | ||
|
||
BUILTIN(__builtin_ptx_read_smid, "i", "nc") | ||
BUILTIN(__builtin_ptx_read_nsmid, "i", "nc") | ||
BUILTIN(__builtin_ptx_read_gridid, "i", "nc") | ||
|
||
BUILTIN(__builtin_ptx_read_lanemask_eq, "i", "nc") | ||
BUILTIN(__builtin_ptx_read_lanemask_le, "i", "nc") | ||
BUILTIN(__builtin_ptx_read_lanemask_lt, "i", "nc") | ||
BUILTIN(__builtin_ptx_read_lanemask_ge, "i", "nc") | ||
BUILTIN(__builtin_ptx_read_lanemask_gt, "i", "nc") | ||
|
||
BUILTIN(__builtin_ptx_read_clock, "i", "n") | ||
BUILTIN(__builtin_ptx_read_clock64, "Li", "n") | ||
|
||
BUILTIN(__builtin_ptx_read_pm0, "i", "n") | ||
BUILTIN(__builtin_ptx_read_pm1, "i", "n") | ||
BUILTIN(__builtin_ptx_read_pm2, "i", "n") | ||
BUILTIN(__builtin_ptx_read_pm3, "i", "n") | ||
|
||
BUILTIN(__builtin_ptx_bar_sync, "vi", "n") | ||
|
||
|
||
#undef BUILTIN |
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,99 @@ | ||
// RUN: %clang_cc1 -triple ptx32-unknown-unknown -emit-llvm -o %t %s | ||
// RUN: %clang_cc1 -triple ptx64-unknown-unknown -emit-llvm -o %t %s | ||
|
||
|
||
int read_tid() { | ||
|
||
int x = __builtin_ptx_read_tid_x(); | ||
int y = __builtin_ptx_read_tid_y(); | ||
int z = __builtin_ptx_read_tid_z(); | ||
int w = __builtin_ptx_read_tid_w(); | ||
|
||
return x + y + z + w; | ||
|
||
} | ||
|
||
int read_ntid() { | ||
|
||
int x = __builtin_ptx_read_ntid_x(); | ||
int y = __builtin_ptx_read_ntid_y(); | ||
int z = __builtin_ptx_read_ntid_z(); | ||
int w = __builtin_ptx_read_ntid_w(); | ||
|
||
return x + y + z + w; | ||
|
||
} | ||
|
||
int read_ctaid() { | ||
|
||
int x = __builtin_ptx_read_ctaid_x(); | ||
int y = __builtin_ptx_read_ctaid_y(); | ||
int z = __builtin_ptx_read_ctaid_z(); | ||
int w = __builtin_ptx_read_ctaid_w(); | ||
|
||
return x + y + z + w; | ||
|
||
} | ||
|
||
int read_nctaid() { | ||
|
||
int x = __builtin_ptx_read_nctaid_x(); | ||
int y = __builtin_ptx_read_nctaid_y(); | ||
int z = __builtin_ptx_read_nctaid_z(); | ||
int w = __builtin_ptx_read_nctaid_w(); | ||
|
||
return x + y + z + w; | ||
|
||
} | ||
|
||
int read_ids() { | ||
|
||
int a = __builtin_ptx_read_laneid(); | ||
int b = __builtin_ptx_read_warpid(); | ||
int c = __builtin_ptx_read_nwarpid(); | ||
int d = __builtin_ptx_read_smid(); | ||
int e = __builtin_ptx_read_nsmid(); | ||
int f = __builtin_ptx_read_gridid(); | ||
|
||
return a + b + c + d + e + f; | ||
|
||
} | ||
|
||
int read_lanemasks() { | ||
|
||
int a = __builtin_ptx_read_lanemask_eq(); | ||
int b = __builtin_ptx_read_lanemask_le(); | ||
int c = __builtin_ptx_read_lanemask_lt(); | ||
int d = __builtin_ptx_read_lanemask_ge(); | ||
int e = __builtin_ptx_read_lanemask_gt(); | ||
|
||
return a + b + c + d + e; | ||
|
||
} | ||
|
||
|
||
long read_clocks() { | ||
|
||
int a = __builtin_ptx_read_clock(); | ||
long b = __builtin_ptx_read_clock64(); | ||
|
||
return (long)a + b; | ||
|
||
} | ||
|
||
int read_pms() { | ||
|
||
int a = __builtin_ptx_read_pm0(); | ||
int b = __builtin_ptx_read_pm1(); | ||
int c = __builtin_ptx_read_pm2(); | ||
int d = __builtin_ptx_read_pm3(); | ||
|
||
return a + b + c + d; | ||
|
||
} | ||
|
||
void sync() { | ||
|
||
__builtin_ptx_bar_sync(0); | ||
|
||
} |