Add CUDA libdevice module to third_party (#5867)
diff --git a/BUILD.bazel b/BUILD.bazel
index 8993d44..18ba639 100644
--- a/BUILD.bazel
+++ b/BUILD.bazel
@@ -22,7 +22,7 @@
# "@bazel_skylib//"
# "@com_google_benchmark//"
# "@cpuinfo//"
-# "@cuda_headers//"
+# "@cuda//"
# "@com_github_dvidelabs_flatcc//"
# "@com_google_googletest//"
# "@llvm-project//"
diff --git a/CMakeLists.txt b/CMakeLists.txt
index f63af86..0b61653 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -383,7 +383,7 @@
include(flatbuffer_c_library)
add_subdirectory(third_party/benchmark EXCLUDE_FROM_ALL)
-add_subdirectory(build_tools/third_party/cuda_headers EXCLUDE_FROM_ALL)
+add_subdirectory(build_tools/third_party/cuda EXCLUDE_FROM_ALL)
add_subdirectory(build_tools/third_party/flatcc EXCLUDE_FROM_ALL)
add_subdirectory(build_tools/third_party/pffft EXCLUDE_FROM_ALL)
add_subdirectory(build_tools/third_party/renderdoc_api EXCLUDE_FROM_ALL)
diff --git a/build_tools/bazel/workspace.bzl b/build_tools/bazel/workspace.bzl
index b04ce63..cfef6f5 100644
--- a/build_tools/bazel/workspace.bzl
+++ b/build_tools/bazel/workspace.bzl
@@ -119,7 +119,7 @@
maybe(
native.new_local_repository,
- name = "cuda_headers",
- build_file = iree_repo_alias + "//:build_tools/third_party/cuda_headers/BUILD.overlay",
- path = paths.join(iree_path, "third_party/cuda_headers"),
+ name = "cuda",
+ build_file = iree_repo_alias + "//:build_tools/third_party/cuda/BUILD.overlay",
+ path = paths.join(iree_path, "third_party/cuda"),
)
diff --git a/build_tools/bazel_to_cmake/bazel_to_cmake_targets.py b/build_tools/bazel_to_cmake/bazel_to_cmake_targets.py
index 89d5401..8bec4aa 100644
--- a/build_tools/bazel_to_cmake/bazel_to_cmake_targets.py
+++ b/build_tools/bazel_to_cmake/bazel_to_cmake_targets.py
@@ -54,7 +54,7 @@
# Vulkan
"@iree_vulkan_headers//:vulkan_headers": ["Vulkan::Headers"],
# Cuda
- "@cuda_headers": ["cuda_headers"],
+ "@cuda//:cuda_headers": ["cuda_headers"],
# The Bazel target maps to the IMPORTED target defined by FindVulkan().
"@vulkan_sdk//:sdk": ["Vulkan::Vulkan"],
# Misc single targets
diff --git a/build_tools/third_party/cuda_headers/BUILD.overlay b/build_tools/third_party/cuda/BUILD.overlay
similarity index 83%
rename from build_tools/third_party/cuda_headers/BUILD.overlay
rename to build_tools/third_party/cuda/BUILD.overlay
index ba40179..d0ae57c 100644
--- a/build_tools/third_party/cuda_headers/BUILD.overlay
+++ b/build_tools/third_party/cuda/BUILD.overlay
@@ -16,6 +16,12 @@
cc_library(
name = "cuda_headers",
- hdrs = ["cuda.h"],
+ hdrs = ["include/cuda.h"],
+ includes = ["include"],
+)
+
+filegroup(
+ name = "libdevice_root",
+ srcs = ["nvvm/libdevice/**"],
)
diff --git a/build_tools/third_party/cuda_headers/CMakeLists.txt b/build_tools/third_party/cuda/CMakeLists.txt
similarity index 91%
rename from build_tools/third_party/cuda_headers/CMakeLists.txt
rename to build_tools/third_party/cuda/CMakeLists.txt
index 8c3992e..c1aba54 100644
--- a/build_tools/third_party/cuda_headers/CMakeLists.txt
+++ b/build_tools/third_party/cuda/CMakeLists.txt
@@ -12,7 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-set(CUDA_HEADERS_API_ROOT "${IREE_ROOT_DIR}/third_party/cuda_headers/")
+set(CUDA_HEADERS_API_ROOT "${IREE_ROOT_DIR}/third_party/cuda/include")
external_cc_library(
PACKAGE
diff --git a/iree/hal/cuda/BUILD b/iree/hal/cuda/BUILD
index c52b0a2..35adb16 100644
--- a/iree/hal/cuda/BUILD
+++ b/iree/hal/cuda/BUILD
@@ -92,7 +92,7 @@
"//iree/base:core_headers",
"//iree/base:tracing",
"//iree/base/internal:dynamic_library",
- "@cuda_headers",
+ "@cuda//:cuda_headers",
],
)
diff --git a/third_party/cuda_headers/LICENSE b/third_party/cuda/LICENSE
similarity index 100%
rename from third_party/cuda_headers/LICENSE
rename to third_party/cuda/LICENSE
diff --git a/third_party/cuda/README.txt b/third_party/cuda/README.txt
new file mode 100644
index 0000000..be1490c
--- /dev/null
+++ b/third_party/cuda/README.txt
@@ -0,0 +1,3 @@
+This folder contains a subset of CUDA SDK headers needed to build IREE.
+It also contains libdevice.10.bc llvm moddule used to import __nv* function
+during cuda kernel compilation.
\ No newline at end of file
diff --git a/third_party/cuda/UPDATING.md b/third_party/cuda/UPDATING.md
new file mode 100644
index 0000000..39f9331
--- /dev/null
+++ b/third_party/cuda/UPDATING.md
@@ -0,0 +1,13 @@
+Those headers come from CUDA SDK.
+
+To update, install CUDA SDK locally:
+```
+sudo apt-get install cuda
+```
+
+Copy cuda.h, version.txt and libdevice.10.bc:
+```
+cp /usr/local/cuda/include/cuda.h ./include/
+cp /usr/local/cuda/version.txt .
+cp /usr/local/cuda/nvvm/libdevice/libdevice.10.bc ./nvvm/libdevice/
+```
diff --git a/third_party/cuda_headers/cuda.h b/third_party/cuda/include/cuda.h
similarity index 100%
rename from third_party/cuda_headers/cuda.h
rename to third_party/cuda/include/cuda.h
diff --git a/third_party/cuda/nvvm/libdevice/libdevice.10.bc b/third_party/cuda/nvvm/libdevice/libdevice.10.bc
new file mode 100644
index 0000000..897c8c9
--- /dev/null
+++ b/third_party/cuda/nvvm/libdevice/libdevice.10.bc
Binary files differ
diff --git a/third_party/cuda_headers/version.txt b/third_party/cuda/version.txt
similarity index 100%
rename from third_party/cuda_headers/version.txt
rename to third_party/cuda/version.txt
diff --git a/third_party/cuda_headers/README.txt b/third_party/cuda_headers/README.txt
deleted file mode 100644
index b437210..0000000
--- a/third_party/cuda_headers/README.txt
+++ /dev/null
@@ -1 +0,0 @@
-This folder contains a subset of CUDA SDK headers needed to build IREE.
\ No newline at end of file
diff --git a/third_party/cuda_headers/UPDATING.md b/third_party/cuda_headers/UPDATING.md
deleted file mode 100644
index 4f0382e..0000000
--- a/third_party/cuda_headers/UPDATING.md
+++ /dev/null
@@ -1,12 +0,0 @@
-Those headers come from CUDA SDK.
-
-To update, install CUDA SDK locally:
-```
-sudo apt-get install cuda
-```
-
-Copy cuda.h and version.txt:
-```
-cp /usr/local/cuda/include/cuda.h .
-cp /usr/local/cuda/version.txt .
-```