Skip to content

missing include <unordered_map> in llvm/sycl/plugins/cuda/pi_cuda.cpp #5264

@jeffhammond

Description

@jeffhammond

I get this error error when I build with Clang and libc++.

You need to include <unordered_map> when you use std::unordered_map. GCC/libstdc++ doesn't care about such errors. I encourage you to QA with Clang/libc++ more often.

Problem

[455/3264] Building CXX object tools/sycl/plugins/cuda/CMakeFiles/pi_cuda.dir/pi_cuda.cpp.o
FAILED: tools/sycl/plugins/cuda/CMakeFiles/pi_cuda.dir/pi_cuda.cpp.o 
/usr/bin/clang++-12  -stdlib=libc++  -DCL_TARGET_OPENCL_VERSION=220 -D_DEBUG -D_GLIBCXX_ASSERTIONS=1 -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -Dpi_cuda_EXPORTS -Itools/sycl/plugins/cuda -I/local/home/jehammond/DPCPP/llvm/sycl/plugins/cuda -Iinclude -I/local/home/jehammond/DPCPP/llvm/llvm/include -I/local/home/jehammond/DPCPP/llvm/sycl/include -isystem _deps/ocl-headers-src -isystem /usr/local/cuda/include -fPIC -fvisibility-inlines-hidden -Werror=date-time -Werror=unguarded-availability-new -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers -pedantic -Wno-long-long -Wc++98-compat-extra-semi -Wimplicit-fallthrough -Wcovered-switch-default -Wno-noexcept-type -Wnon-virtual-dtor -Wdelete-non-virtual-dtor -Wsuggest-override -Wstring-conversion -Wmisleading-indentation -fdiagnostics-color -ffunction-sections -fdata-sections -Wall -Wextra -Wno-deprecated-declarations -Werror -Wno-covered-switch-default -O3 -DNDEBUG -fPIC   -UNDEBUG -fvisibility=hidden -std=c++17 -MD -MT tools/sycl/plugins/cuda/CMakeFiles/pi_cuda.dir/pi_cuda.cpp.o -MF tools/sycl/plugins/cuda/CMakeFiles/pi_cuda.dir/pi_cuda.cpp.o.d -o tools/sycl/plugins/cuda/CMakeFiles/pi_cuda.dir/pi_cuda.cpp.o -c /local/home/jehammond/DPCPP/llvm/sycl/plugins/cuda/pi_cuda.cpp
In file included from /local/home/jehammond/DPCPP/llvm/sycl/plugins/cuda/pi_cuda.cpp:17:
/local/home/jehammond/DPCPP/llvm/sycl/plugins/cuda/pi_cuda.hpp:532:8: error: no template named 'unordered_map' in namespace 'std'
  std::unordered_map<std::string, std::tuple<uint32_t, uint32_t, uint32_t>>
  ~~~~~^
/local/home/jehammond/DPCPP/llvm/sycl/plugins/cuda/pi_cuda.cpp:579:39: error: unused parameter 'program' [-Werror,-Wunused-parameter]
std::string getKernelNames(pi_program program) {
                                      ^
2 errors generated.

Solution

diff --git a/sycl/plugins/cuda/pi_cuda.hpp b/sycl/plugins/cuda/pi_cuda.hpp
index 50f93135c75d..7be4c9251ad0 100644
--- a/sycl/plugins/cuda/pi_cuda.hpp
+++ b/sycl/plugins/cuda/pi_cuda.hpp
@@ -31,6 +31,7 @@
 #include <vector>
 #include <functional>
 #include <mutex>
+#include <unordered_map>
 
 extern "C" {
 

The other issue

I don't think this complies with the LLVM conventions but since you enable -Werror in your buildbot scripts, you should silence the warning somehow.

diff --git a/sycl/plugins/cuda/pi_cuda.cpp b/sycl/plugins/cuda/pi_cuda.cpp
index 8a4794242728..6ea46a270230 100644
--- a/sycl/plugins/cuda/pi_cuda.cpp
+++ b/sycl/plugins/cuda/pi_cuda.cpp
@@ -577,6 +577,7 @@ pi_result _pi_program::build_program(const char *build_options) {
 /// Note: Another alternative is to add kernel names as metadata, like with
 ///       reqd_work_group_size.
 std::string getKernelNames(pi_program program) {
+  (void)program;
   cl::sycl::detail::pi::die("getKernelNames not implemented");
   return {};
 }

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingcompilerCompiler related issuecudaCUDA back-end

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions