Skip to content

Commit 95460c9

Browse files
[ILUVATAR_GPU] Update for compiling CUDAExtension for iluvatar (#73762)
1 parent 3889dfb commit 95460c9

File tree

4 files changed

+19
-2
lines changed

4 files changed

+19
-2
lines changed

paddle/common/backend_header.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
#include <cuda.h>
1919
#endif
2020

21-
#if defined(__CUDACC__) && CUDA_VERSION >= 11000
21+
#if defined(__CUDACC__) && (CUDA_VERSION >= 11000 || defined(PADDLE_WITH_COREX))
2222
#define PADDLE_CUDA_BF16
2323
#include <cuda_bf16.h>
2424
#endif

paddle/utils/flat_hash_map.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -684,7 +684,8 @@ class sherwood_v3_table : private EntryAlloc, private Hasher, private Equal {
684684

685685
size_t num_buckets_for_reserve(size_t num_elements) const {
686686
return static_cast<size_t>(std::ceil(
687-
num_elements / std::min(0.5, static_cast<double>(_max_load_factor))));
687+
num_elements /
688+
std::min((double)0.5, static_cast<double>(_max_load_factor))));
688689
}
689690
void rehash_for_other_container(const sherwood_v3_table &other) {
690691
rehash(

python/paddle/utils/cpp_extension/cpp_extension.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -467,6 +467,20 @@ def unix_custom_compile_single_file(
467467
# {'nvcc': {}, 'cxx: {}}
468468
if isinstance(cflags, dict):
469469
cflags = cflags['hipcc']
470+
elif core.is_compiled_with_custom_device("iluvatar_gpu"):
471+
ixcc_cmd = os.path.join(
472+
os.getenv("COREX_HOME", "/usr/local/corex/"),
473+
'bin',
474+
'clang++',
475+
)
476+
if not os.path.isfile(ixcc_cmd):
477+
raise ValueError(
478+
"Corex compiler is unavailable, please set `COREX_HOME` to specify it."
479+
)
480+
self.set_executable('compiler_so', ixcc_cmd)
481+
# {'nvcc': {}, 'cxx: {}}
482+
if isinstance(cflags, dict):
483+
cflags = cflags['nvcc']
470484
else:
471485
assert (
472486
CUDA_HOME is not None

python/paddle/utils/cpp_extension/extension_utils.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -394,6 +394,8 @@ def prepare_unix_cudaflags(cflags):
394394
*cflags,
395395
*get_rocm_arch_flags(cflags),
396396
]
397+
elif core.is_compiled_with_custom_device("iluvatar_gpu"):
398+
cflags = [*COMMON_NVCC_FLAGS, '-fPIC', '-DPADDLE_WITH_COREX', *cflags]
397399
else:
398400
cflags = [
399401
*COMMON_NVCC_FLAGS,

0 commit comments

Comments
 (0)