From 4947ab50ba8f97ff14e4901cf70cef1a9bcc9f5d Mon Sep 17 00:00:00 2001 From: James Sharpe Date: Sat, 15 Oct 2022 20:33:08 +0000 Subject: [PATCH 1/3] Add thrust and cub repos --- cuda/private/repositories.bzl | 18 ++++++++++++++ third_party/BUILD.bazel | 0 third_party/cub.BUILD | 45 +++++++++++++++++++++++++++++++++++ third_party/thrust.BUILD | 37 ++++++++++++++++++++++++++++ 4 files changed, 100 insertions(+) create mode 100644 third_party/BUILD.bazel create mode 100644 third_party/cub.BUILD create mode 100644 third_party/thrust.BUILD diff --git a/cuda/private/repositories.bzl b/cuda/private/repositories.bzl index b3d1c312..217f9cd2 100644 --- a/cuda/private/repositories.bzl +++ b/cuda/private/repositories.bzl @@ -210,4 +210,22 @@ def rules_cuda_dependencies(): ], ) + maybe( + name = "thrust", + repo_rule = http_archive, + build_file = "@rules_cuda//third_party:thrust.BUILD", + sha256 = "d021e37f5aac30fd1b9737865399feb57db8e601ae2fc0af3cd41784435e9523", + strip_prefix = "thrust-1.17.2", + urls = ["https://github.com/NVIDIA/thrust/archive/refs/tags/1.17.2.tar.gz"], + ) + + maybe( + name = "cub", + repo_rule = http_archive, + build_file = "@rules_cuda//third_party:cub.BUILD", + sha256 = "1013a595794548c359f22c07e1f8c620b97e3a577f7e8496d9407f74566a3e2a", + strip_prefix = "cub-1.17.2", + urls = ["https://github.com/NVIDIA/cub/archive/refs/tags/1.17.2.tar.gz"], + ) + _local_cuda(name = "local_cuda") diff --git a/third_party/BUILD.bazel b/third_party/BUILD.bazel new file mode 100644 index 00000000..e69de29b diff --git a/third_party/cub.BUILD b/third_party/cub.BUILD new file mode 100644 index 00000000..3f427b94 --- /dev/null +++ b/third_party/cub.BUILD @@ -0,0 +1,45 @@ +load("@rules_cc//cc:defs.bzl", "cc_library") +load("@rules_license//rules:license.bzl", "license") + +package(default_applicable_licenses = [":license"]) + +license( + name = "license", + license_kinds = [ + "@rules_license//licenses/spdx:BSD-3-Clause", + ], + license_text = "LICENSE.TXT", +) + +filegroup( + name = "include-src", + srcs = glob([ + "cub/*.h", + ]), +) + +cc_library( + name = "includes", + hdrs = [":include-src"], + includes = ["."], + textual_hdrs = glob([ + "cub/*.cuh", + "cub/agent/*.cuh", + "cub/block/*.cuh", + "cub/block/specializations/*.cuh", + "cub/device/*.cuh", + "cub/device/dispatch/*.cuh", + "cub/grid/*.cuh", + "cub/warp/*.cuh", + "cub/warp/specializations/*.cuh", + "cub/iterator/*.cuh", + "cub/thread/*.cuh", + "cub/detail/*.cuh", + ]), +) + +cc_library( + name = "cub", + visibility = ["//visibility:public"], + deps = [":includes"], +) diff --git a/third_party/thrust.BUILD b/third_party/thrust.BUILD new file mode 100644 index 00000000..0ab5a5ae --- /dev/null +++ b/third_party/thrust.BUILD @@ -0,0 +1,37 @@ +load("@rules_cc//cc:defs.bzl", "cc_library") +load("@rules_license//rules:license.bzl", "license") + +package(default_applicable_licenses = [":license"]) + +license( + name = "license", + license_kinds = [ + "@rules_license//licenses/spdx:Apache-2.0", + "@rules_license//licenses/spdx:BSL-1.0", + ], + license_text = "LICENSE", +) + +filegroup( + name = "include-src", + srcs = glob([ + "thrust/*.h", + "thrust/**/*.h", + "thrust/**/*.inl", + ]), +) + +cc_library( + name = "includes", + hdrs = [":include-src"], + includes = ["."], +) + +cc_library( + name = "thrust", + visibility = ["//visibility:public"], + deps = [ + ":includes", + "@cub", + ], +) From c39950a2a574c7f561f2b30bfafc840214ef697f Mon Sep 17 00:00:00 2001 From: James Sharpe Date: Sat, 15 Oct 2022 21:05:49 +0000 Subject: [PATCH 2/3] Comment out rules_license for now --- third_party/cub.BUILD | 18 +++++++++--------- third_party/thrust.BUILD | 20 ++++++++++---------- 2 files changed, 19 insertions(+), 19 deletions(-) diff --git a/third_party/cub.BUILD b/third_party/cub.BUILD index 3f427b94..46a6dd2e 100644 --- a/third_party/cub.BUILD +++ b/third_party/cub.BUILD @@ -1,15 +1,15 @@ load("@rules_cc//cc:defs.bzl", "cc_library") -load("@rules_license//rules:license.bzl", "license") +#load("@rules_license//rules:license.bzl", "license") -package(default_applicable_licenses = [":license"]) +#package(default_applicable_licenses = [":license"]) -license( - name = "license", - license_kinds = [ - "@rules_license//licenses/spdx:BSD-3-Clause", - ], - license_text = "LICENSE.TXT", -) +#license( +# name = "license", +# license_kinds = [ +# "@rules_license//licenses/spdx:BSD-3-Clause", +# ], +# license_text = "LICENSE.TXT", +#) filegroup( name = "include-src", diff --git a/third_party/thrust.BUILD b/third_party/thrust.BUILD index 0ab5a5ae..aa67dc95 100644 --- a/third_party/thrust.BUILD +++ b/third_party/thrust.BUILD @@ -1,16 +1,16 @@ load("@rules_cc//cc:defs.bzl", "cc_library") -load("@rules_license//rules:license.bzl", "license") +#load("@rules_license//rules:license.bzl", "license") -package(default_applicable_licenses = [":license"]) +#package(default_applicable_licenses = [":license"]) -license( - name = "license", - license_kinds = [ - "@rules_license//licenses/spdx:Apache-2.0", - "@rules_license//licenses/spdx:BSL-1.0", - ], - license_text = "LICENSE", -) +#license( +# name = "license", +# license_kinds = [ +# "@rules_license//licenses/spdx:Apache-2.0", +# "@rules_license//licenses/spdx:BSL-1.0", +# ], +# license_text = "LICENSE", +#) filegroup( name = "include-src", From cf17ea98fc73314d18cd051a848e7c9df0a97325 Mon Sep 17 00:00:00 2001 From: James Sharpe Date: Sat, 15 Oct 2022 21:05:27 +0000 Subject: [PATCH 3/3] Use external thrust --- examples/thrust/BUILD.bazel | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/thrust/BUILD.bazel b/examples/thrust/BUILD.bazel index c25291a7..0c726383 100644 --- a/examples/thrust/BUILD.bazel +++ b/examples/thrust/BUILD.bazel @@ -5,7 +5,7 @@ load("//cuda:defs.bzl", "cuda_library") cuda_library( name = "thrust_cu", srcs = ["thrust.cu"], - deps = ["@local_cuda//:thrust"], + deps = ["@thrust"], ) # Run with 'bazel run //examples/thrust:main'