Skip to content
This repository has been archived by the owner on May 14, 2024. It is now read-only.

Commit

Permalink
Merge branch 'develop' into rsp
Browse files Browse the repository at this point in the history
  • Loading branch information
cjatin authored Jul 28, 2023
2 parents 928e0a8 + 863ece8 commit 5e94da1
Show file tree
Hide file tree
Showing 6 changed files with 57 additions and 44 deletions.
21 changes: 11 additions & 10 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -90,19 +90,20 @@ set(CPACK_PACKAGE_VERSION "${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSIO

# Exclude Windows specific BAT scripts from install/packaging for Linux.
if (NOT WIN32)
set(exclusion_pattern "*.bat")
install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/bin
DESTINATION .
USE_SOURCE_PERMISSIONS
DIRECTORY_PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE
FILES_MATCHING
PATTERN "*"
PATTERN "*.bat" EXCLUDE)
else ()
set(exclusion_pattern "")
install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/bin
DESTINATION .
USE_SOURCE_PERMISSIONS
DIRECTORY_PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)
endif()

install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/bin
DESTINATION .
USE_SOURCE_PERMISSIONS
DIRECTORY_PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE
FILES_MATCHING
PATTERN "*"
PATTERN ${exclusion_pattern} EXCLUDE )

install(FILES
"LICENSE.txt"
"README.md"
Expand Down
35 changes: 17 additions & 18 deletions bin/hipcc.pl
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ BEGIN

use hipvars;
$isWindows = $hipvars::isWindows;
$doubleQuote = $hipvars::doubleQuote;
$HIP_RUNTIME = $hipvars::HIP_RUNTIME;
$HIP_PLATFORM = $hipvars::HIP_PLATFORM;
$HIP_COMPILER = $hipvars::HIP_COMPILER;
Expand All @@ -131,6 +132,10 @@ BEGIN
$HIP_VERSION = $hipvars::HIP_VERSION;
$HIP_ROCCLR_HOME = $hipvars::HIP_ROCCLR_HOME;

sub get_normalized_path {
return $doubleQuote . $_[0] . $doubleQuote;
}

if ($HIP_PLATFORM eq "amd") {
$HIP_INCLUDE_PATH = "$HIP_ROCCLR_HOME/include";
if (!defined $HIP_LIB_PATH) {
Expand All @@ -155,20 +160,17 @@ BEGIN
if($isWindows) {
$execExtension = ".exe";
}
$HIPCC="$HIP_CLANG_PATH/clang++" . $execExtension;
$HIPCC=get_normalized_path("$HIP_CLANG_PATH/clang++" . $execExtension);

# If $HIPCC clang++ is not compiled, use clang instead
if ( ! -e $HIPCC ) {
$HIPCC="$HIP_CLANG_PATH/clang" . $execExtension;
$HIPCC=get_normalized_path("$HIP_CLANG_PATH/clang" . $execExtension);
$HIPLDFLAGS = "--driver-mode=g++";
}
# to avoid using dk linker or MSVC linker
if($isWindows) {
$HIPLDFLAGS .= " -fuse-ld=lld";
$HIPLDFLAGS .= " --ld-path=$HIP_CLANG_PATH/lld-link.exe";

# escape possible spaces in path name
$HIPCC =~ s/\s/\\$&/g;
$HIPLDFLAGS .= " --ld-path=" . get_normalized_path("$HIP_CLANG_PATH/lld-link.exe");
}

# get Clang RT Builtin path
Expand Down Expand Up @@ -204,21 +206,21 @@ BEGIN
print ("CUDA_PATH=$CUDA_PATH\n");
}

$HIPCC="$CUDA_PATH/bin/nvcc";
$HIPCC=get_normalized_path("$CUDA_PATH/bin/nvcc");
$HIPCXXFLAGS .= " -Wno-deprecated-gpu-targets ";
$HIPCXXFLAGS .= " -isystem $CUDA_PATH/include";
$HIPCFLAGS .= " -isystem $CUDA_PATH/include";
$HIPCXXFLAGS .= " -isystem " . get_normalized_path("$CUDA_PATH/include");
$HIPCFLAGS .= " -isystem " . get_normalized_path("$CUDA_PATH/include");

$HIPLDFLAGS = " -Wno-deprecated-gpu-targets -lcuda -lcudart -L$CUDA_PATH/lib64";
$HIPLDFLAGS = " -Wno-deprecated-gpu-targets -lcuda -lcudart -L" . get_normalized_path("$CUDA_PATH/lib64");
} else {
printf ("error: unknown HIP_PLATFORM = '$HIP_PLATFORM'");
printf (" or HIP_COMPILER = '$HIP_COMPILER'");
exit (-1);
}

# Add paths to common HIP includes:
$HIPCXXFLAGS .= " -isystem \"$HIP_INCLUDE_PATH\"" ;
$HIPCFLAGS .= " -isystem \"$HIP_INCLUDE_PATH\"" ;
$HIPCXXFLAGS .= " -isystem " . get_normalized_path("$HIP_INCLUDE_PATH");
$HIPCFLAGS .= " -isystem " . get_normalized_path("$HIP_INCLUDE_PATH");

my $compileOnly = 0;
my $needCXXFLAGS = 0; # need to add CXX flags to compile step
Expand Down Expand Up @@ -297,7 +299,7 @@ BEGIN

if ($skipOutputFile) {
# TODO: handle filename with shell metacharacters
$toolArgs .= " \"$arg\"";
$toolArgs .= " " . get_normalized_path("$arg");
$prevArg = $arg;
$skipOutputFile = 0;
next;
Expand Down Expand Up @@ -478,9 +480,6 @@ BEGIN
if (not $isWindows and $escapeArg) {
$arg =~ s/[^-a-zA-Z0-9_=+,.@\/]/\\$&/g;
}
if ($isWindows and $escapeArg) {
$arg =~ s/[^-a-zA-Z0-9_=+,.:@\/\\]/\\$&/g;
}
$toolArgs .= " $arg" unless $swallowArg;
$prevArg = $arg;
}
Expand Down Expand Up @@ -576,14 +575,14 @@ BEGIN

# If the HIP_PATH env var is defined, pass that path to Clang
if ($ENV{'HIP_PATH'}) {
my $hip_path_flag = " --hip-path=\"$HIP_PATH\"";
my $hip_path_flag = " --hip-path=" . get_normalized_path("$HIP_PATH");
$HIPCXXFLAGS .= $hip_path_flag;
$HIPLDFLAGS .= $hip_path_flag;
}

if ($hasHIP) {
if (defined $DEVICE_LIB_PATH) {
$HIPCXXFLAGS .= " --hip-device-lib-path=\"$DEVICE_LIB_PATH\"";
$HIPCXXFLAGS .= " --hip-device-lib-path=" . get_normalized_path("$DEVICE_LIB_PATH");
}
}

Expand Down
23 changes: 18 additions & 5 deletions bin/hipvars.pm
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ use Cwd;
use File::Basename;

$HIP_BASE_VERSION_MAJOR = "5";
$HIP_BASE_VERSION_MINOR = "5";
$HIP_BASE_VERSION_MINOR = "7";
$HIP_BASE_VERSION_PATCH = "0";

#---
Expand Down Expand Up @@ -61,6 +61,7 @@ sub can_run {
}

$isWindows = ($^O eq 'MSWin32' or $^O eq 'msys');
$doubleQuote = "\"";

#
# TODO: Fix rpath LDFLAGS settings
Expand All @@ -74,6 +75,10 @@ $isWindows = ($^O eq 'MSWin32' or $^O eq 'msys');
# ROCM_PATH is defined relative to HIP_PATH else it is hardcoded to /opt/rocm.
#
$HIP_PATH=$ENV{'HIP_PATH'} // dirname(Cwd::abs_path("$0/../")); # use parent directory of hipcc
if ($isWindows and defined $ENV{'HIP_PATH'}) {
$HIP_PATH =~ s/^"(.*)"$/$1/;
$HIP_PATH =~ s/\\/\//g;
}
if (-e "$HIP_PATH/bin/rocm_agent_enumerator") {
$ROCM_PATH=$ENV{'ROCM_PATH'} // "$HIP_PATH"; # use HIP_PATH
}elsif (-e "$HIP_PATH/../bin/rocm_agent_enumerator") { # case for backward compatibility
Expand All @@ -82,9 +87,13 @@ if (-e "$HIP_PATH/bin/rocm_agent_enumerator") {
$ROCM_PATH=$ENV{'ROCM_PATH'} // "/opt/rocm";
}
$CUDA_PATH=$ENV{'CUDA_PATH'} // '/usr/local/cuda';
if ($isWindows and defined $ENV{'CUDA_PATH'}) {
$CUDA_PATH =~ s/^"(.*)"$/$1/;
$CUDA_PATH =~ s/\\/\//g;
}

# Windows/Distro's have a different structure, all binaries are with hipcc
if (-e "$HIP_PATH/bin/clang" or -e "$HIP_PATH/bin/clang.exe") {
if ($isWindows or -e "$HIP_PATH/bin/clang") {
$HIP_CLANG_PATH=$ENV{'HIP_CLANG_PATH'} // "$HIP_PATH/bin";
} else {
$HIP_CLANG_PATH=$ENV{'HIP_CLANG_PATH'} // "$ROCM_PATH/llvm/bin";
Expand Down Expand Up @@ -120,9 +129,9 @@ if (defined $HIP_RUNTIME and $HIP_RUNTIME eq "rocclr" and !defined $HIP_ROCCLR_H
}

if (not defined $HIP_PLATFORM) {
if (can_run("$HIP_CLANG_PATH/clang++") or can_run("clang++")) {
if (can_run($doubleQuote . "$HIP_CLANG_PATH/clang++" . $doubleQuote) or can_run("clang++")) {
$HIP_PLATFORM = "amd";
} elsif (can_run("$CUDA_PATH/bin/nvcc") or can_run("nvcc")) {
} elsif (can_run($doubleQuote . "$CUDA_PATH/bin/nvcc" . $doubleQuote) or can_run("nvcc")) {
$HIP_PLATFORM = "nvidia";
$HIP_COMPILER = "nvcc";
$HIP_RUNTIME = "cuda";
Expand Down Expand Up @@ -150,7 +159,11 @@ if ($HIP_COMPILER eq "clang") {
#---
# Read .hipVersion
my %hipVersion = ();
parse_config_file("$hipvars::HIP_PATH/bin/.hipVersion", \%hipVersion);
if ($isWindows) {
parse_config_file("$hipvars::HIP_PATH/bin/.hipVersion", \%hipVersion);
} else {
parse_config_file("$hipvars::HIP_PATH/share/hip/version", \%hipVersion);
}
$HIP_VERSION_MAJOR = $hipVersion{'HIP_VERSION_MAJOR'} // $HIP_BASE_VERSION_MAJOR;
$HIP_VERSION_MINOR = $hipVersion{'HIP_VERSION_MINOR'} // $HIP_BASE_VERSION_MINOR;
$HIP_VERSION_PATCH = $hipVersion{'HIP_VERSION_PATCH'} // $HIP_BASE_VERSION_PATCH;
Expand Down
2 changes: 1 addition & 1 deletion docs/.sphinx/requirements.in
Original file line number Diff line number Diff line change
@@ -1 +1 @@
rocm-docs-core==0.14.0
rocm-docs-core==0.19.0
8 changes: 2 additions & 6 deletions docs/.sphinx/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,6 @@ jinja2==3.1.2
# via
# myst-parser
# sphinx
linkify-it-py==1.0.3
# via myst-parser
markdown-it-py==2.2.0
# via
# mdit-py-plugins
Expand All @@ -62,7 +60,7 @@ mdit-py-plugins==0.3.5
# via myst-parser
mdurl==0.1.2
# via markdown-it-py
myst-parser[linkify]==1.0.0
myst-parser==1.0.0
# via rocm-docs-core
packaging==23.0
# via
Expand Down Expand Up @@ -94,7 +92,7 @@ requests==2.28.2
# via
# pygithub
# sphinx
rocm-docs-core==0.14.0
rocm-docs-core==0.19.0
# via -r requirements.in
smmap==5.0.0
# via gitdb
Expand Down Expand Up @@ -137,8 +135,6 @@ sphinxcontrib-serializinghtml==1.1.5
# via sphinx
typing-extensions==4.5.0
# via pydata-sphinx-theme
uc-micro-py==1.0.1
# via linkify-it-py
urllib3==1.26.15
# via requests
wrapt==1.15.0
Expand Down
12 changes: 8 additions & 4 deletions hipcc-backward-compat.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,11 @@ endfunction()
# Create symlink to binaries
create_binary_symlink()
# TODO: Following has to modified if component based installation is required
install(DIRECTORY ${HIPCC_WRAPPER_BIN_DIR} DESTINATION hip
FILES_MATCHING
PATTERN "*"
PATTERN ${exclusion_pattern} EXCLUDE )
if (NOT WIN32)
install(DIRECTORY ${HIPCC_WRAPPER_BIN_DIR} DESTINATION hip)
else()
install(DIRECTORY ${HIPCC_WRAPPER_BIN_DIR} DESTINATION hip
FILES_MATCHING
PATTERN "*"
PATTERN "*.bat" EXCLUDE )
endif()

0 comments on commit 5e94da1

Please sign in to comment.