Commit 55f8d22
committed
devicelib: keep <cstring> in device pass; resolve std::mem* via using-decls
The new-hip-tests / HIP7 work needs device-side memset/memcpy plus host
string functions to coexist with libstdc++ <cstring> in single-source HIP.
Two problems had to be solved together:
1. Host build break. <cstring> does 'using ::memset/::memcpy', so *defining*
std::memset/std::memcpy (as the earlier approach did) collides with it:
'target of using declaration conflicts with declaration already in scope'.
That broke host compilation on every lane (pocl, macOS, salami, rusticl),
and on macOS surfaced as 'call to memcpy is ambiguous' in hip_fp16_gcc.h.
Fix: instead of redefining them, declare the __device__ memset/memcpy
overloads at global scope and surface them into std:: with using-decls.
A duplicate 'using ::memset/::memcpy' is harmless and, placed after the
__device__ overloads, makes std::memcpy/std::memset resolve to the device
(__chip_*) versions in device code.
2. Library device pass. Library headers (e.g. rocPRIM) reference strcmp/
memset/memcpy in __host__ functions (device-property setup), whose bodies
are still parsed during the device pass. Guarding <cstring> out of device
compilation (a previous attempt to keep the SPIR-V module small) left those
identifiers undeclared and broke the device pass -- hipCUB/rocPRIM/rocRAND
failed to build on the x86 Intel GPU libraries lane. Fix: include <cstring>
unconditionally. It contributes only declarations, not definitions, so it
does not enlarge the module; the using-decls above keep device mem* calls
pointing at __chip_*.
The DG2 IGC kernel-drop that motivated the device-pass <cstring> guard is
tracked/handled separately (PR #1297) and is not reintroduced by this change.1 parent 27f407c commit 55f8d22
1 file changed
Lines changed: 22 additions & 16 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
29 | 29 | | |
30 | 30 | | |
31 | 31 | | |
32 | | - | |
33 | | - | |
34 | | - | |
35 | | - | |
36 | | - | |
37 | | - | |
38 | | - | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
39 | 42 | | |
40 | 43 | | |
41 | 44 | | |
| |||
148 | 151 | | |
149 | 152 | | |
150 | 153 | | |
151 | | - | |
152 | | - | |
153 | | - | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
154 | 164 | | |
155 | | - | |
156 | | - | |
157 | | - | |
158 | | - | |
159 | | - | |
160 | | - | |
| 165 | + | |
| 166 | + | |
161 | 167 | | |
162 | 168 | | |
163 | 169 | | |
| |||
0 commit comments