Line
Link Here
|
0 |
-- a/third_party/gpus/rocm_configure.bzl |
0 |
++ bthird_party/gpus/rocm_configure.bzl |
Lines 43-49
Link Here
|
43 |
|
43 |
|
44 |
_DEFAULT_ROCM_VERSION = "" |
44 |
_DEFAULT_ROCM_VERSION = "" |
45 |
_DEFAULT_MIOPEN_VERSION = "" |
45 |
_DEFAULT_MIOPEN_VERSION = "" |
46 |
_DEFAULT_ROCM_TOOLKIT_PATH = "/opt/rocm" |
46 |
_DEFAULT_ROCM_TOOLKIT_PATH = "/usr" |
47 |
_DEFAULT_ROCM_AMDGPU_TARGETS = ["gfx803", "gfx900"] |
47 |
_DEFAULT_ROCM_AMDGPU_TARGETS = ["gfx803", "gfx900"] |
48 |
|
48 |
|
49 |
def verify_build_defines(params): |
49 |
def verify_build_defines(params): |
Lines 182-188
Link Here
|
182 |
inc_dirs = get_cxx_inc_directories(repository_ctx, cc) |
182 |
inc_dirs = get_cxx_inc_directories(repository_ctx, cc) |
183 |
|
183 |
|
184 |
# Add numpy headers |
184 |
# Add numpy headers |
185 |
inc_dirs.append("/usr/lib/python2.7/dist-packages/numpy/core/include") |
185 |
inc_dirs.append("/usr/lib/python3.7/site-packages/numpy/core/include") |
186 |
|
186 |
|
187 |
return inc_dirs |
187 |
return inc_dirs |
188 |
|
188 |
|
Lines 204-254
Link Here
|
204 |
inc_dirs.append(rocm_config.rocm_toolkit_path + "/include") |
204 |
inc_dirs.append(rocm_config.rocm_toolkit_path + "/include") |
205 |
|
205 |
|
206 |
# Add HSA headers |
206 |
# Add HSA headers |
207 |
inc_dirs.append(rocm_config.rocm_toolkit_path + "/hsa/include") |
207 |
inc_dirs.append(rocm_config.rocm_toolkit_path + "/include/hsa") |
208 |
|
208 |
|
209 |
# Add HIP headers |
209 |
# Add HIP headers |
210 |
inc_dirs.append(rocm_config.rocm_toolkit_path + "/include/hip") |
210 |
inc_dirs.append(rocm_config.rocm_toolkit_path + "/lib/hip/include/hip") |
211 |
inc_dirs.append(rocm_config.rocm_toolkit_path + "/include/hip/hcc_detail") |
211 |
inc_dirs.append(rocm_config.rocm_toolkit_path + "/lib/hip/include/hip/hcc_detail") |
212 |
inc_dirs.append(rocm_config.rocm_toolkit_path + "/hip/include") |
212 |
inc_dirs.append(rocm_config.rocm_toolkit_path + "/lib/hip/include") |
213 |
|
213 |
|
214 |
# Add HIP-Clang headers |
214 |
# Add HIP-Clang headers |
215 |
inc_dirs.append(rocm_config.rocm_toolkit_path + "/llvm/lib/clang/8.0/include") |
215 |
inc_dirs.append(rocm_config.rocm_toolkit_path + "/lib/llvm/roc/lib/clang/11.0.0/include") |
216 |
inc_dirs.append(rocm_config.rocm_toolkit_path + "/llvm/lib/clang/9.0.0/include") |
|
|
217 |
inc_dirs.append(rocm_config.rocm_toolkit_path + "/llvm/lib/clang/10.0.0/include") |
218 |
inc_dirs.append(rocm_config.rocm_toolkit_path + "/llvm/lib/clang/11.0.0/include") |
219 |
|
216 |
|
220 |
# Add rocrand and hiprand headers |
217 |
# Add rocrand and hiprand headers |
221 |
inc_dirs.append(rocm_config.rocm_toolkit_path + "/rocrand/include") |
218 |
inc_dirs.append(rocm_config.rocm_toolkit_path + "/include/rocrand") |
222 |
inc_dirs.append(rocm_config.rocm_toolkit_path + "/hiprand/include") |
219 |
inc_dirs.append(rocm_config.rocm_toolkit_path + "/include/hiprand") |
223 |
|
220 |
|
224 |
# Add rocfft headers |
221 |
# Add rocfft headers |
225 |
inc_dirs.append(rocm_config.rocm_toolkit_path + "/rocfft/include") |
222 |
inc_dirs.append(rocm_config.rocm_toolkit_path + "/include/rocFFT") |
226 |
|
223 |
|
227 |
# Add rocBLAS headers |
224 |
# Add rocBLAS headers |
228 |
inc_dirs.append(rocm_config.rocm_toolkit_path + "/rocblas/include") |
225 |
inc_dirs.append(rocm_config.rocm_toolkit_path + "/include/rocblas") |
229 |
|
226 |
|
230 |
# Add MIOpen headers |
227 |
# Add MIOpen headers |
231 |
inc_dirs.append(rocm_config.rocm_toolkit_path + "/miopen/include") |
228 |
inc_dirs.append(rocm_config.rocm_toolkit_path + "/include/miopen") |
232 |
|
|
|
233 |
# Add RCCL headers |
234 |
inc_dirs.append(rocm_config.rocm_toolkit_path + "/rccl/include") |
235 |
|
229 |
|
236 |
# Add hcc headers |
230 |
# Add hcc headers |
237 |
inc_dirs.append(rocm_config.rocm_toolkit_path + "/hcc/include") |
231 |
inc_dirs.append(rocm_config.rocm_toolkit_path + "/lib/hcc/3.3/include") |
238 |
inc_dirs.append(rocm_config.rocm_toolkit_path + "/hcc/compiler/lib/clang/7.0.0/include/") |
232 |
inc_dirs.append(rocm_config.rocm_toolkit_path + "/lib/hcc/3.3/lib/clang/11.0.0/include") |
239 |
inc_dirs.append(rocm_config.rocm_toolkit_path + "/hcc/lib/clang/7.0.0/include") |
|
|
240 |
|
241 |
# Newer hcc builds use/are based off of clang 8.0.0. |
242 |
inc_dirs.append(rocm_config.rocm_toolkit_path + "/hcc/compiler/lib/clang/8.0.0/include/") |
243 |
inc_dirs.append(rocm_config.rocm_toolkit_path + "/hcc/lib/clang/8.0.0/include") |
244 |
|
245 |
# Support hcc based off clang 9.0.0, included in ROCm2.2 |
246 |
inc_dirs.append(rocm_config.rocm_toolkit_path + "/hcc/compiler/lib/clang/9.0.0/include/") |
247 |
inc_dirs.append(rocm_config.rocm_toolkit_path + "/hcc/lib/clang/9.0.0/include") |
248 |
|
249 |
# Support hcc based off clang 10.0.0, included in ROCm2.8 |
250 |
inc_dirs.append(rocm_config.rocm_toolkit_path + "/hcc/compiler/lib/clang/10.0.0/include/") |
251 |
inc_dirs.append(rocm_config.rocm_toolkit_path + "/hcc/lib/clang/10.0.0/include") |
252 |
|
233 |
|
253 |
return inc_dirs |
234 |
return inc_dirs |
254 |
|
235 |
|
Lines 330-336
Link Here
|
330 |
return "True" |
311 |
return "True" |
331 |
|
312 |
|
332 |
# grep for "HIP_COMPILER=clang" in /opt/rocm/hip/lib/.hipInfo |
313 |
# grep for "HIP_COMPILER=clang" in /opt/rocm/hip/lib/.hipInfo |
333 |
cmd = "grep HIP_COMPILER=clang %s/hip/lib/.hipInfo || true" % rocm_config.rocm_toolkit_path |
314 |
cmd = "grep HIP_COMPILER=clang %s/lib/hip/lib/.hipInfo || true" % rocm_config.rocm_toolkit_path |
334 |
grep_result = execute(repository_ctx, [bash_bin, "-c", cmd], empty_stdout_fine = True) |
315 |
grep_result = execute(repository_ctx, [bash_bin, "-c", cmd], empty_stdout_fine = True) |
335 |
result = grep_result.stdout.strip() |
316 |
result = grep_result.stdout.strip() |
336 |
if result == "HIP_COMPILER=clang": |
317 |
if result == "HIP_COMPILER=clang": |
Lines 436-448
Link Here
|
436 |
libs_paths = [ |
417 |
libs_paths = [ |
437 |
(name, _rocm_lib_paths(repository_ctx, name, path)) |
418 |
(name, _rocm_lib_paths(repository_ctx, name, path)) |
438 |
for name, path in [ |
419 |
for name, path in [ |
439 |
("hip_hcc", rocm_config.rocm_toolkit_path), |
420 |
("hip_hcc", rocm_config.rocm_toolkit_path + "/lib/hip/lib"), |
440 |
("rocblas", rocm_config.rocm_toolkit_path + "/rocblas"), |
421 |
("rocblas", rocm_config.rocm_toolkit_path + "/lib64"), |
441 |
("rocfft", rocm_config.rocm_toolkit_path + "/rocfft"), |
422 |
("rocfft", rocm_config.rocm_toolkit_path + "/lib64"), |
442 |
("hiprand", rocm_config.rocm_toolkit_path + "/hiprand"), |
423 |
("hiprand", rocm_config.rocm_toolkit_path + "/lib64"), |
443 |
("MIOpen", rocm_config.rocm_toolkit_path + "/miopen"), |
424 |
("MIOpen", rocm_config.rocm_toolkit_path + "/lib64"), |
444 |
("rccl", rocm_config.rocm_toolkit_path + "/rccl"), |
425 |
("rccl", rocm_config.rocm_toolkit_path + "/lib64"), |
445 |
("hipsparse", rocm_config.rocm_toolkit_path + "/hipsparse"), |
426 |
("hipsparse", rocm_config.rocm_toolkit_path + "/lib64"), |
446 |
] |
427 |
] |
447 |
] |
428 |
] |
448 |
|
429 |
|
Lines 606-648
Link Here
|
606 |
# rocm_toolkit_path |
587 |
# rocm_toolkit_path |
607 |
rocm_toolkit_path = rocm_config.rocm_toolkit_path |
588 |
rocm_toolkit_path = rocm_config.rocm_toolkit_path |
608 |
copy_rules = [ |
589 |
copy_rules = [ |
609 |
make_copy_dir_rule( |
590 |
# make_copy_dir_rule( |
610 |
repository_ctx, |
591 |
# repository_ctx, |
611 |
name = "rocm-include", |
592 |
# name = "rocm-include", |
612 |
src_dir = rocm_toolkit_path + "/include", |
593 |
# src_dir = rocm_toolkit_path + "/include", |
613 |
out_dir = "rocm/include", |
594 |
# out_dir = "rocm/include", |
614 |
), |
595 |
# ), |
615 |
make_copy_dir_rule( |
596 |
make_copy_dir_rule( |
616 |
repository_ctx, |
597 |
repository_ctx, |
617 |
name = "rocfft-include", |
598 |
name = "rocfft-include", |
618 |
src_dir = rocm_toolkit_path + "/rocfft/include", |
599 |
src_dir = rocm_toolkit_path + "/include/rocFFT", |
619 |
out_dir = "rocm/include/rocfft", |
600 |
out_dir = "rocm/include/rocfft", |
620 |
), |
601 |
), |
621 |
make_copy_dir_rule( |
602 |
make_copy_dir_rule( |
622 |
repository_ctx, |
603 |
repository_ctx, |
623 |
name = "rocblas-include", |
604 |
name = "rocblas-include", |
624 |
src_dir = rocm_toolkit_path + "/rocblas/include", |
605 |
src_dir = rocm_toolkit_path + "/include/rocblas", |
625 |
out_dir = "rocm/include/rocblas", |
606 |
out_dir = "rocm/include/rocblas", |
626 |
), |
607 |
), |
627 |
make_copy_dir_rule( |
608 |
make_copy_dir_rule( |
628 |
repository_ctx, |
609 |
repository_ctx, |
629 |
name = "miopen-include", |
610 |
name = "miopen-include", |
630 |
src_dir = rocm_toolkit_path + "/miopen/include", |
611 |
src_dir = rocm_toolkit_path + "/include/miopen", |
631 |
out_dir = "rocm/include/miopen", |
612 |
out_dir = "rocm/include/miopen", |
|
|
613 |
), |
614 |
# make_copy_dir_rule( |
615 |
# repository_ctx, |
616 |
# name = "rccl-include", |
617 |
# src_dir = rocm_toolkit_path + "/rccl/include", |
618 |
# out_dir = "rocm/include/rccl", |
619 |
# ), |
620 |
make_copy_dir_rule( |
621 |
repository_ctx, |
622 |
name = "hipsparse-include", |
623 |
src_dir = rocm_toolkit_path + "/include/hipsparse", |
624 |
out_dir = "rocm/include/hipsparse", |
632 |
), |
625 |
), |
633 |
make_copy_dir_rule( |
626 |
make_copy_dir_rule( |
634 |
repository_ctx, |
627 |
repository_ctx, |
635 |
name = "rccl-include", |
628 |
name = "hipcub-include", |
636 |
src_dir = rocm_toolkit_path + "/rccl/include", |
629 |
src_dir = rocm_toolkit_path + "/include/hipcub", |
637 |
out_dir = "rocm/include/rccl", |
630 |
out_dir = "rocm/include/hipcub", |
638 |
), |
631 |
), |
639 |
make_copy_dir_rule( |
632 |
make_copy_dir_rule( |
640 |
repository_ctx, |
633 |
repository_ctx, |
641 |
name = "hipsparse-include", |
634 |
name = "rocprim-include", |
642 |
src_dir = rocm_toolkit_path + "/hipsparse/include", |
635 |
src_dir = rocm_toolkit_path + "/include/rocprim", |
643 |
out_dir = "rocm/include/hipsparse", |
636 |
out_dir = "rocm/include/rocprim", |
|
|
637 |
), |
638 |
make_copy_dir_rule( |
639 |
repository_ctx, |
640 |
name = "hip-include", |
641 |
src_dir = rocm_toolkit_path + "/lib/hip/include/hip/", |
642 |
out_dir = "rocm/include/hip", |
643 |
), |
644 |
make_copy_dir_rule( |
645 |
repository_ctx, |
646 |
name = "hiprand-include", |
647 |
src_dir = rocm_toolkit_path + "/include/hiprand", |
648 |
out_dir = "rocm/include/hiprand", |
649 |
), |
650 |
make_copy_dir_rule( |
651 |
repository_ctx, |
652 |
name = "rocblas-include-main", |
653 |
src_dir = rocm_toolkit_path + "/include/rocblas", |
654 |
out_dir = "rocm/include", |
644 |
), |
655 |
), |
645 |
] |
656 |
] |
|
|
657 |
|
658 |
# Copy required include files |
659 |
copy_rules.append(make_copy_files_rule( |
660 |
repository_ctx, |
661 |
name = "rocm-include", |
662 |
srcs = [ |
663 |
"/usr/include/rccl.h", |
664 |
"/usr/include/rocrand/rocrand.h", |
665 |
"/usr/include/rocrand/rocrand_discrete_types.h", |
666 |
"/usr/include/rocrand/rocrand_version.h", |
667 |
], |
668 |
outs = [ |
669 |
"rocm/include/rccl/rccl.h", |
670 |
"rocm/include/rocrand.h", |
671 |
"rocm/include/rocrand_discrete_types.h", |
672 |
"rocm/include/rocrand_version.h", |
673 |
], |
674 |
)) |
646 |
|
675 |
|
647 |
rocm_libs = _find_libs(repository_ctx, rocm_config, bash_bin) |
676 |
rocm_libs = _find_libs(repository_ctx, rocm_config, bash_bin) |
648 |
rocm_lib_srcs = [] |
677 |
rocm_lib_srcs = [] |
Lines 685-691
Link Here
|
685 |
'":rocfft-include",\n' + |
714 |
'":rocfft-include",\n' + |
686 |
'":rocblas-include",\n' + |
715 |
'":rocblas-include",\n' + |
687 |
'":miopen-include",\n' + |
716 |
'":miopen-include",\n' + |
688 |
'":rccl-include",\n' + |
717 |
'":hipcub-include",\n' + |
|
|
718 |
'":rocprim-include",\n' + |
719 |
'":hip-include",\n' + |
720 |
'":hiprand-include",\n' + |
721 |
'":rocblas-include-main",\n' + |
689 |
'":hipsparse-include",'), |
722 |
'":hipsparse-include",'), |
690 |
}, |
723 |
}, |
691 |
) |
724 |
) |
Lines 702-708
Link Here
|
702 |
|
735 |
|
703 |
rocm_defines["%{host_compiler_prefix}"] = host_compiler_prefix |
736 |
rocm_defines["%{host_compiler_prefix}"] = host_compiler_prefix |
704 |
|
737 |
|
705 |
rocm_defines["%{linker_bin_path}"] = rocm_config.rocm_toolkit_path + "/hcc/compiler/bin" |
738 |
rocm_defines["%{linker_bin_path}"] = rocm_config.rocm_toolkit_path + "/lib/hcc/3.3/bin/" |
706 |
|
739 |
|
707 |
# For gcc, do not canonicalize system header paths; some versions of gcc |
740 |
# For gcc, do not canonicalize system header paths; some versions of gcc |
708 |
# pick the shortest possible path for system includes when creating the |
741 |
# pick the shortest possible path for system includes when creating the |
Lines 753-766
Link Here
|
753 |
tpl_paths["crosstool:clang/bin/crosstool_wrapper_driver_rocm"], |
786 |
tpl_paths["crosstool:clang/bin/crosstool_wrapper_driver_rocm"], |
754 |
{ |
787 |
{ |
755 |
"%{cpu_compiler}": str(cc), |
788 |
"%{cpu_compiler}": str(cc), |
756 |
"%{hipcc_path}": rocm_config.rocm_toolkit_path + "/bin/hipcc", |
789 |
"%{hipcc_path}": rocm_config.rocm_toolkit_path + "/lib/hip/bin/hipcc", |
757 |
"%{hipcc_env}": _hipcc_env(repository_ctx), |
790 |
"%{hipcc_env}": _hipcc_env(repository_ctx), |
758 |
"%{hipcc_is_hipclang}": _hipcc_is_hipclang(repository_ctx, rocm_config, bash_bin), |
791 |
"%{hipcc_is_hipclang}": _hipcc_is_hipclang(repository_ctx, rocm_config, bash_bin), |
759 |
"%{rocr_runtime_path}": rocm_config.rocm_toolkit_path + "/lib", |
792 |
"%{rocr_runtime_path}": rocm_config.rocm_toolkit_path + "/lib64", |
760 |
"%{rocr_runtime_library}": "hsa-runtime64", |
793 |
"%{rocr_runtime_library}": "hsa-runtime64", |
761 |
"%{hip_runtime_path}": rocm_config.rocm_toolkit_path + "/hip/lib", |
794 |
"%{hip_runtime_path}": rocm_config.rocm_toolkit_path + "/lib/hip/lib", |
762 |
"%{hip_runtime_library}": "hip_hcc", |
795 |
"%{hip_runtime_library}": "hip_hcc", |
763 |
"%{hcc_runtime_path}": rocm_config.rocm_toolkit_path + "/hcc/lib", |
796 |
"%{hcc_runtime_path}": rocm_config.rocm_toolkit_path + "/lib/hcc/3.3/lib", |
764 |
"%{hcc_runtime_library}": "mcwamp", |
797 |
"%{hcc_runtime_library}": "mcwamp", |
765 |
"%{crosstool_verbose}": _crosstool_verbose(repository_ctx), |
798 |
"%{crosstool_verbose}": _crosstool_verbose(repository_ctx), |
766 |
"%{gcc_host_compiler_path}": str(cc), |
799 |
"%{gcc_host_compiler_path}": str(cc), |