Skip to content

Commit 5cfb739

Browse files
authored
Add absl cuda warnings patch (microsoft#27096)
Some PRs that use core/common/inlined_containers.h can cause failures in the CUDA CI pipeline. ``` E:\_work\_temp\build\RelWithDebInfo\vcpkg_installed\x64-windows-static-md\include\absl/hash/internal/hash.h(481): error microsoft#68-D: integer conversion resulted in a change of sign [E:\_work\_temp\build\RelWithDebInfo\onnxruntime_providers_cuda.vcxproj] sizeof(T) == -1, ^ Remark: The warnings can be suppressed with "-diag-suppress <warning-number>" E:\_work\_temp\build\RelWithDebInfo\vcpkg_installed\x64-windows-static-md\include\absl/hash/hash.h(337): error microsoft#549-D: variable "s" is used before its value is set [E:\_work\_temp\build\RelWithDebInfo\onnxruntime_providers_cuda.vcxproj] return s; ^ E:\_work\_temp\build\RelWithDebInfo\vcpkg_installed\x64-windows-static-md\include\absl/container/internal/raw_hash_set.h(468): error microsoft#69-D: integer conversion resulted in truncation [E:\_work\_temp\build\RelWithDebInfo\onnxruntime_providers_cuda.vcxproj] static_cast<uint16_t>(reinterpret_cast<uintptr_t>(&seed)); ^ 3 errors detected in the compilation of "E:/_work/onnxruntime/onnxruntime/onnxruntime/contrib_ops/cuda/sparse/block_mask.cu". ``` This change adds a patch to Abseil to mitigate those failures. This solution has been verified to be effective in PR microsoft#27087.
1 parent 76675fa commit 5cfb739

4 files changed

Lines changed: 83 additions & 1 deletion

File tree

cmake/external/abseil-cpp.cmake

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ else()
2121
endif()
2222

2323
if(Patch_FOUND AND WIN32)
24-
set(ABSL_PATCH_COMMAND ${Patch_EXECUTABLE} --binary --ignore-whitespace -p1 < ${PROJECT_SOURCE_DIR}/patches/abseil/absl_windows.patch)
24+
set(ABSL_PATCH_COMMAND ${Patch_EXECUTABLE} --binary --ignore-whitespace -p1 < ${PROJECT_SOURCE_DIR}/patches/abseil/absl_windows.patch &&
25+
${Patch_EXECUTABLE} --binary --ignore-whitespace -p1 < ${PROJECT_SOURCE_DIR}/patches/abseil/absl_cuda_warnings.patch)
2526
else()
2627
set(ABSL_PATCH_COMMAND "")
2728
endif()
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
diff --git a/absl/hash/internal/hash.h b/absl/hash/internal/hash.h
2+
index 1234567..abcdefg 100644
3+
--- a/absl/hash/internal/hash.h
4+
+++ b/absl/hash/internal/hash.h
5+
@@ -477,7 +477,7 @@ H AbslHashValue(H hash_state, T (&)[N]) {
6+
template <typename H, typename T, size_t N>
7+
H AbslHashValue(H hash_state, T (&)[N]) {
8+
static_assert(
9+
- sizeof(T) == -1,
10+
+ sizeof(T) == size_t(-1),
11+
"Hashing C arrays is not allowed. For string literals, wrap the literal "
12+
"in absl::string_view(). To hash the array contents, use "
13+
"absl::MakeSpan() or make the array an std::array. To hash the array "
14+
diff --git a/absl/hash/hash.h b/absl/hash/hash.h
15+
index 1234567..abcdefg 100644
16+
--- a/absl/hash/hash.h
17+
+++ b/absl/hash/hash.h
18+
@@ -333,7 +333,8 @@ class HashState : public hash_internal::HashStateBase<HashState> {
19+
absl::enable_if_t<
20+
std::is_base_of<hash_internal::HashStateBase<T>, T>::value, int> = 0>
21+
static HashState Create(T* state) {
22+
- HashState s;
23+
+ HashState s = {};
24+
+ (void)s;
25+
s.Init(state);
26+
return s;
27+
}
28+
diff --git a/absl/container/internal/raw_hash_set.h b/absl/container/internal/raw_hash_set.h
29+
index 1234567..abcdefg 100644
30+
--- a/absl/container/internal/raw_hash_set.h
31+
+++ b/absl/container/internal/raw_hash_set.h
32+
@@ -464,7 +464,7 @@ inline uint16_t NextSeed() {
33+
inline uint16_t NextSeed() {
34+
static_assert(PerTableSeed::kBitCount == 16);
35+
thread_local uint16_t seed =
36+
- static_cast<uint16_t>(reinterpret_cast<uintptr_t>(&seed));
37+
+ static_cast<uint16_t>(reinterpret_cast<uintptr_t>(&seed) & 0xFFFFu);
38+
seed += uint16_t{0xad53};
39+
return seed;
40+
}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
diff --git a/absl/hash/internal/hash.h b/absl/hash/internal/hash.h
2+
index 1234567..abcdefg 100644
3+
--- a/absl/hash/internal/hash.h
4+
+++ b/absl/hash/internal/hash.h
5+
@@ -477,7 +477,7 @@ H AbslHashValue(H hash_state, T (&)[N]) {
6+
template <typename H, typename T, size_t N>
7+
H AbslHashValue(H hash_state, T (&)[N]) {
8+
static_assert(
9+
- sizeof(T) == -1,
10+
+ sizeof(T) == size_t(-1),
11+
"Hashing C arrays is not allowed. For string literals, wrap the literal "
12+
"in absl::string_view(). To hash the array contents, use "
13+
"absl::MakeSpan() or make the array an std::array. To hash the array "
14+
diff --git a/absl/hash/hash.h b/absl/hash/hash.h
15+
index 1234567..abcdefg 100644
16+
--- a/absl/hash/hash.h
17+
+++ b/absl/hash/hash.h
18+
@@ -333,7 +333,8 @@ class HashState : public hash_internal::HashStateBase<HashState> {
19+
absl::enable_if_t<
20+
std::is_base_of<hash_internal::HashStateBase<T>, T>::value, int> = 0>
21+
static HashState Create(T* state) {
22+
- HashState s;
23+
+ HashState s = {};
24+
+ (void)s;
25+
s.Init(state);
26+
return s;
27+
}
28+
diff --git a/absl/container/internal/raw_hash_set.h b/absl/container/internal/raw_hash_set.h
29+
index 1234567..abcdefg 100644
30+
--- a/absl/container/internal/raw_hash_set.h
31+
+++ b/absl/container/internal/raw_hash_set.h
32+
@@ -464,7 +464,7 @@ inline uint16_t NextSeed() {
33+
inline uint16_t NextSeed() {
34+
static_assert(PerTableSeed::kBitCount == 16);
35+
thread_local uint16_t seed =
36+
- static_cast<uint16_t>(reinterpret_cast<uintptr_t>(&seed));
37+
+ static_cast<uint16_t>(reinterpret_cast<uintptr_t>(&seed) & 0xFFFFu);
38+
seed += uint16_t{0xad53};
39+
return seed;
40+
}

cmake/vcpkg-ports/abseil/portfile.cmake

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ vcpkg_from_github(
99
SHA512 4ee1a217203933382e728d354a149253a517150eee7580a0abecc69584b2eb200d91933ef424487e3a3fe0e8ab5e77b0288485cac982171b3585314a4417e7d4
1010
HEAD_REF master
1111
PATCHES absl_windows.patch
12+
absl_cuda_warnings.patch
1213
)
1314

1415

0 commit comments

Comments
 (0)