Skip to content
Merged
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
30 changes: 30 additions & 0 deletions .bazelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# +------------------------------------------------------------+
# | Build Configurations |
# +------------------------------------------------------------+
# Do not show warnings from external dependencies.
build --output_filter="^//"

build --show_timestamps

build --flag_alias=cuda_archs=@rules_cuda//cuda:archs

# Work around the sandbox issue.
build --spawn_strategy=local


# Consider warning as error.
# inference is not included because tensorflow uses the same log macros with glog and it will
# cause re-definition warning.
build --per_file_copt="-\\.$@-Wall,-Wextra,-Werror"
build --per_file_copt="-\\.$,external/.*@-w"
build --per_file_copt="-\\.$,third_party/.*@-w"

# If a command fails, print out the full command line.
build --verbose_failures

# Enable C++17
build --cxxopt="-std=c++17"
# Workaround as cpp toolchain: stop passing -std=c++0x per default · Issue #18181 · bazelbuild/bazel
build --host_cxxopt="-std=c++17"
# Enable colorful output of GCC
build --cxxopt="-fdiagnostics-color=always"
1 change: 1 addition & 0 deletions .bazelversion
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
8.4.1
19 changes: 17 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,20 @@ vsxmake2022
# CMake Cache
CMakeBuild/

# IntelliJ IDEA
.idea/
# Bazel build
bazel-*
MODULE.bazel.lock

# JetBrains IDEs
.idea/

.vs/

.cache

compile_commands.json

# //external is reserved by Bazel and needed for hedron_compile_commands
external/

presubmit.yml
74 changes: 74 additions & 0 deletions BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
load("@bazel_skylib//rules:common_settings.bzl", "bool_flag")
load("@rules_cc//cc:defs.bzl", "cc_library")
load("@rules_license//rules:license.bzl", "license")

package(
default_applicable_licenses = [":license"],
default_visibility = ["//visibility:public"],
)

license(
name = "license",
package_name = "hugooole_muda",
package_url = "https://github.com/hugooole/muda",
license_text = "LICENSE",
license_kinds = ["@rules_license//licenses/spdx:Apache-2.0"],
)

bool_flag(
name = "muda_check",
build_setting_default = True,
)

config_setting(
name = "muda_check_on",
flag_values = {":muda_check": "True"},
)

bool_flag(
name = "muda_compute_graph",
build_setting_default = False,
)

config_setting(
name = "muda_compute_graph_on",
flag_values = {":muda_compute_graph": "True"},
)

bool_flag(
name = "muda_nvtx3",
build_setting_default = False,
)

config_setting(
name = "muda_nvtx3_on",
flag_values = {":muda_nvtx3": "True"},
)

cc_library(
name = "muda",
hdrs = glob(
[
"src/**/*.h",
"src/**/*.hpp",
"src/**/*.inl",
"src/**/*.cuh",
],
allow_empty = True,
),
copts = [
"--expt-relaxed-constexpr",
"--extended-lambda",
],
defines = select({
":muda_check_on": ["MUDA_CHECK_ON"],
"//conditions:default": ["MUDA_CHECK_ON=0"],
}) + select({
":muda_compute_graph_on": ["MUDA_COMPUTE_GRAPH_ON"],
"//conditions:default": [],
}) + select({
":muda_nvtx3_on": ["MUDA_NVTX3_ON"],
"//conditions:default": [],
}),
includes = ["src"],
)
42 changes: 42 additions & 0 deletions MODULE.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
"""muda"""

module(
name = "hugooole_muda",
version = "1.0.0-beta",
compatibility_level = 1,
)

bazel_dep(name = "rules_cc", version = "0.2.8")

bazel_dep(name = "rules_license", version = "1.0.0")

bazel_dep(name = "eigen", version = "3.4.1", dev_dependency = True)
bazel_dep(name = "bazel_skylib", version = "1.8.2")

# rules_cuda is required for CUDA toolchain support
bazel_dep(name = "rules_cuda", version = "0.2.4")
git_override(
module_name = "rules_cuda",
remote = "https://github.com/bazel-contrib/rules_cuda.git",
commit = "1bf21ef1eee98042c0b2c5f39365ac39a4217c53",
)



cuda = use_extension("@rules_cuda//cuda:extensions.bzl", "toolchain")
cuda.toolkit(
name = "cuda",
toolkit_path = "",
)
use_repo(cuda, "cuda")

# Optional for debug: Hedron's Compile Commands Extractor for Bazel
# https://github.com/hedronvision/bazel-compile-commands-extractor
# bazel_dep(name = "hedron_compile_commands", dev_dependency = True)
# git_override(
# module_name = "hedron_compile_commands",
# remote = "https://github.com/hedronvision/bazel-compile-commands-extractor.git",
# commit = "abb61a688167623088f8768cc9264798df6a9d10",
# # Replace the commit hash (above) with the latest (https://github.com/hedronvision/bazel-compile-commands-extractor/commits/main).
# # Even better, set up Renovate and let it do the work for you (see "Suggestion: Updates" in the README).
# )
23 changes: 23 additions & 0 deletions example/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
load("@rules_cuda//cuda:defs.bzl", "cuda_binary")

cuda_binary(
name = "examples",
srcs = glob([
"**/*.cu",
"**/*.cpp",
]),
hdrs = [
"example_common.h",
],
copts = [
"-std=c++20",
],
includes = ["."],
rdc = True,
visibility = ["//:__pkg__"],
deps = [
"//:muda",
"//third_party:catch2",
"@eigen",
],
)
2 changes: 1 addition & 1 deletion example/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ set_target_properties(muda_example PROPERTIES CUDA_SEPARABLE_COMPILATION ON)
# target_link_libraries(muda_example PRIVATE fmt::fmt-header-only)
target_include_directories(muda_example PRIVATE
"${PROJECT_SOURCE_DIR}/example"
"${PROJECT_SOURCE_DIR}/external")
"${PROJECT_SOURCE_DIR}/third_party")
target_link_libraries(muda_example PRIVATE muda Eigen3::Eigen)
source_group(TREE "${PROJECT_SOURCE_DIR}/example" PREFIX "example" FILES ${SOURCE_FILES})
source_group(TREE "${PROJECT_SOURCE_DIR}/src" PREFIX "src" FILES ${MUDA_HEADER_FILES})
Expand Down
2 changes: 1 addition & 1 deletion src/muda/launch/stream.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ class Stream
std::byte* workspace(size_t byte_size);

private:
Stream(nullptr_t)
Stream(std::nullptr_t)
: m_handle(nullptr)
{
}
Expand Down
75 changes: 75 additions & 0 deletions test/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
load("@rules_cuda//cuda:defs.bzl", "cuda_test")

cuda_test(
name = "muda_unit_test",
srcs = glob([
"unit_test/**/*.cu",
"unit_test/**/*.cpp",
]),
copts = [
"--expt-relaxed-constexpr",
"--extended-lambda",
"-std=c++20",
],
rdc = True,
deps = [
"//:muda",
"//third_party:catch2",
"@eigen",
],
)

cuda_test(
name = "muda_eigen_test",
srcs = glob([
"eigen_test/**/*.cu",
"eigen_test/**/*.cpp",
]),
hdrs = glob(
[
"eigen_test/**/*.h",
"eigen_test/**/*.hpp",
],
allow_empty = True,
),
copts = [
"--expt-relaxed-constexpr",
"--extended-lambda",
"-std=c++20",
],
rdc = True,
deps = [
"//:muda",
"//third_party:catch2",
"@eigen",
],
)

cuda_test(
name = "muda_linear_system_test",
srcs = glob([
"linear_system_test/**/*.cu",
"linear_system_test/**/*.cpp",
]),
hdrs = glob(
[
"linear_system_test/**/*.h",
"linear_system_test/**/*.hpp",
],
allow_empty = True,
),
copts = [
"--expt-relaxed-constexpr",
"--extended-lambda",
"-std=c++20",
],
rdc = True,
deps = [
"//:muda",
"//third_party:catch2",
"@eigen",
"@cuda//:cublas",
"@cuda//:cusolver",
"@cuda//:cusparse",
],
)
2 changes: 1 addition & 1 deletion test/eigen_test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ target_compile_features(muda_eigen_test PRIVATE cxx_std_20)
set_target_properties(muda_eigen_test PROPERTIES CUDA_SEPARABLE_COMPILATION ON)
target_include_directories(muda_eigen_test PRIVATE
"${PROJECT_SOURCE_DIR}/test"
"${PROJECT_SOURCE_DIR}/external")
"${PROJECT_SOURCE_DIR}/third_party")
target_link_libraries(muda_eigen_test PRIVATE muda Eigen3::Eigen)
source_group(TREE "${PROJECT_SOURCE_DIR}/test" PREFIX "test" FILES ${SOURCE})
source_group(TREE "${PROJECT_SOURCE_DIR}/src" PREFIX "src" FILES ${MUDA_HEADER_FILES})
Expand Down
2 changes: 1 addition & 1 deletion test/linear_system_test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ target_compile_features(muda_linear_system_test PRIVATE cxx_std_20)
set_target_properties(muda_linear_system_test PROPERTIES CUDA_SEPARABLE_COMPILATION ON)
target_include_directories(muda_linear_system_test PRIVATE
"${PROJECT_SOURCE_DIR}/test"
"${PROJECT_SOURCE_DIR}/external")
"${PROJECT_SOURCE_DIR}/third_party")
target_link_libraries(muda_linear_system_test PRIVATE muda cusparse cublas cusolver Eigen3::Eigen)
source_group(TREE "${PROJECT_SOURCE_DIR}/test" PREFIX "test" FILES ${SOURCE})
source_group(TREE "${PROJECT_SOURCE_DIR}/src" PREFIX "src" FILES ${MUDA_HEADER_FILES})
Expand Down
2 changes: 1 addition & 1 deletion test/spgrid_test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ target_compile_features(muda_spgrid_test PRIVATE cxx_std_20)
set_target_properties(muda_spgrid_test PROPERTIES CUDA_SEPARABLE_COMPILATION ON)
target_include_directories(muda_spgrid_test PRIVATE
"${PROJECT_SOURCE_DIR}/test"
"${PROJECT_SOURCE_DIR}/external")
"${PROJECT_SOURCE_DIR}/third_party")
target_link_libraries(muda_spgrid_test PRIVATE muda Eigen3::Eigen)

add_test(NAME muda_spgrid_test COMMAND muda_spgrid_test)
2 changes: 1 addition & 1 deletion test/unit_test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ target_compile_features(muda_unit_test PRIVATE cxx_std_20)
set_target_properties(muda_unit_test PROPERTIES CUDA_SEPARABLE_COMPILATION ON)
target_include_directories(muda_unit_test PRIVATE
"${PROJECT_SOURCE_DIR}/test"
"${PROJECT_SOURCE_DIR}/external")
"${PROJECT_SOURCE_DIR}/third_party")
target_link_libraries(muda_unit_test PRIVATE muda cusparse cublas cusolver Eigen3::Eigen)
target_compile_definitions(muda_unit_test PRIVATE "-DMUDA_TEST_DATA_DIR=R\"(${PROJECT_SOURCE_DIR}/test/data)\"")
source_group(TREE "${PROJECT_SOURCE_DIR}/test" PREFIX "test" FILES ${SOURCE})
Expand Down
11 changes: 11 additions & 0 deletions third_party/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
load("@rules_cc//cc:defs.bzl", "cc_library")

package(default_visibility = ["//visibility:public"])

cc_library(
name = "catch2",
hdrs = glob([
"catch2/**/*.hpp",
]),
includes = ["."],
)
File renamed without changes.