Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add thrust and cub repos #38

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions cuda/private/repositories.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -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"],
)

Comment on lines +213 to +230
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They are not mandatory, please move them into third_party/ also. Otherwise, our core rules depends on not in use remote files. Lets keep them minimal.

_local_cuda(name = "local_cuda")
2 changes: 1 addition & 1 deletion examples/thrust/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
Empty file added third_party/BUILD.bazel
Empty file.
45 changes: 45 additions & 0 deletions third_party/cub.BUILD
Original file line number Diff line number Diff line change
@@ -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",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe call them include-hdrs.

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",
Comment on lines +26 to +37
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any reason to make the glob so detailed? This prone to be affected by upstream implemtation details change. Why not just glob([cub/**/*.cuh]).

]),
)

cc_library(
name = "cub",
visibility = ["//visibility:public"],
deps = [":includes"],
)
37 changes: 37 additions & 0 deletions third_party/thrust.BUILD
Original file line number Diff line number Diff line change
@@ -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",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same

srcs = glob([
"thrust/*.h",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line is redundent.

"thrust/**/*.h",
"thrust/**/*.inl",
]),
)

cc_library(
name = "includes",
hdrs = [":include-src"],
includes = ["."],
)

cc_library(
name = "thrust",
visibility = ["//visibility:public"],
deps = [
":includes",
"@cub",
],
)