-
-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add cuda_toolkit rule and CudaToolkitInfo provider for tool File reso…
…lution.
- Loading branch information
Showing
12 changed files
with
137 additions
and
24 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package(default_visibility = ["//visibility:public"]) | ||
|
||
cc_binary( | ||
name = "nvlink", | ||
srcs = ["dummy.cpp"], | ||
defines = ["TOOLNAME=nvlink"], | ||
) | ||
|
||
exports_files(["link.stub"]) | ||
|
||
cc_binary( | ||
name = "bin2c", | ||
srcs = ["dummy.cpp"], | ||
defines = ["TOOLNAME=bin2c"], | ||
) | ||
|
||
cc_binary( | ||
name = "fatbinary", | ||
srcs = ["dummy.cpp"], | ||
defines = ["TOOLNAME=fatbinary"], | ||
) |
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 @@ | ||
#include "cstdio" | ||
|
||
#define TO_STRING_IND(X) #X | ||
#define TO_STRING(X) TO_STRING_IND(X) | ||
|
||
int main(int argc, char* argv[]) { | ||
std::printf("ERROR: " TO_STRING(TOOLNAME) " of cuda toolkit does not exist\n"); | ||
return -1; | ||
} |
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 @@ | ||
#error link.stub of cuda toolkit does not exist |
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,26 @@ | ||
load("//cuda/private:providers.bzl", "CudaToolkitInfo") | ||
|
||
def _impl(ctx): | ||
version_major, version_minor = ctx.attr.version.split(".")[:2] | ||
return CudaToolkitInfo( | ||
path = ctx.attr.path, | ||
version_major = int(version_major), | ||
version_minor = int(version_minor), | ||
nvlink = ctx.file.nvlink, | ||
link_stub = ctx.file.link_stub, | ||
bin2c = ctx.file.bin2c, | ||
fatbinary = ctx.file.fatbinary, | ||
) | ||
|
||
cuda_toolkit = rule( | ||
implementation = _impl, | ||
attrs = { | ||
"path": attr.string(mandatory = True), | ||
"version": attr.string(mandatory = True), | ||
"nvlink": attr.label(allow_single_file = True), | ||
"link_stub": attr.label(allow_single_file = True), | ||
"bin2c": attr.label(allow_single_file = True), | ||
"fatbinary": attr.label(allow_single_file = True), | ||
}, | ||
provides = [CudaToolkitInfo], | ||
) |
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
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