From 0b5fe1601c958c79d948907afd5352ed4c0152d5 Mon Sep 17 00:00:00 2001 From: "Yaxun (Sam) Liu" Date: Wed, 13 Jun 2018 10:01:14 -0400 Subject: [PATCH 1/7] Let hipcc handle static library for hip-clang only if it contains bundles [ROCm/clr commit: d442a570023a144b42b57d56ca74b89491e0c2e7] --- projects/clr/hipamd/bin/hipcc | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/projects/clr/hipamd/bin/hipcc b/projects/clr/hipamd/bin/hipcc index 03f35b27fc..ca504fae4e 100755 --- a/projects/clr/hipamd/bin/hipcc +++ b/projects/clr/hipamd/bin/hipcc @@ -377,14 +377,31 @@ foreach $arg (@ARGV) while (my $line = <$in>) { chomp $line; if ($line =~ m/\.a$/) { + my $libFile = $line; my $path = abs_path($line); my @objs = split ('\n', `cd $tmpdir; ar xv $path`); + ## Check if all files in .a are object files. + my $allIsObj = 1; + my $realObjs = ""; foreach my $obj (@objs) { chomp $obj; $obj =~ s/^x - //; $obj = "$tmpdir/$obj"; - push (@inputs, $obj); - $new_arg = "$new_arg $obj"; + my $fileType = `file $obj`; + my $isObj = ($fileType =~ m/ELF/ or $fileType =~ m/COFF/); + $allIsObj = ($allIsObj and $isObj); + if ($isObj) { + $realObjs = $realObjs . " " . $obj; + } else { + push (@inputs, $obj); + $new_arg = "$new_arg $obj"; + } + } + if ($allIsObj) { + print $out "$line\n"; + } else { + system("cd $tmpdir; ar c $libFile $realObjs"); + print $out "$tmpdir/$libFile\n"; } } else { print $out "$line\n"; From 5efe15283bd750620a82d7b9b410dfce2bf22b2e Mon Sep 17 00:00:00 2001 From: "Yaxun (Sam) Liu" Date: Sun, 17 Jun 2018 12:18:37 -0400 Subject: [PATCH 2/7] Fix handling of static library in hipcc for hip-clang [ROCm/clr commit: fd03c8fc183246663542cef221e343cb42612bc6] --- projects/clr/hipamd/bin/hipcc | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/projects/clr/hipamd/bin/hipcc b/projects/clr/hipamd/bin/hipcc index ca504fae4e..4c526bd2c7 100755 --- a/projects/clr/hipamd/bin/hipcc +++ b/projects/clr/hipamd/bin/hipcc @@ -391,17 +391,20 @@ foreach $arg (@ARGV) my $isObj = ($fileType =~ m/ELF/ or $fileType =~ m/COFF/); $allIsObj = ($allIsObj and $isObj); if ($isObj) { - $realObjs = $realObjs . " " . $obj; + $realObjs = ($realObjs . " " . $obj); } else { push (@inputs, $obj); $new_arg = "$new_arg $obj"; } } + chomp $realObjs; if ($allIsObj) { print $out "$line\n"; - } else { - system("cd $tmpdir; ar c $libFile $realObjs"); - print $out "$tmpdir/$libFile\n"; + } elsif ($realObjs) { + my $libBaseName = basename($libFile, ".a"); + $libBaseName = mktemp($libBaseName . "XXXX") . ".a"; + system("cd $tmpdir; ar c $libBaseName $realObjs"); + print $out "$tmpdir/$libBaseName\n"; } } else { print $out "$line\n"; From 4831cd44fc9412de9868677b31a02cf757b3a8a7 Mon Sep 17 00:00:00 2001 From: "Yaxun (Sam) Liu" Date: Mon, 18 Jun 2018 21:43:24 -0400 Subject: [PATCH 3/7] Let hipcc handle library with extension lo for hip-clang [ROCm/clr commit: 454d45e5bbeba09ec6cfc11ab7715710e233211c] --- projects/clr/hipamd/bin/hipcc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/projects/clr/hipamd/bin/hipcc b/projects/clr/hipamd/bin/hipcc index 4c526bd2c7..f5fe4249ca 100755 --- a/projects/clr/hipamd/bin/hipcc +++ b/projects/clr/hipamd/bin/hipcc @@ -376,7 +376,7 @@ foreach $arg (@ARGV) open my $out, ">", $new_file or die "$new_file: $!"; while (my $line = <$in>) { chomp $line; - if ($line =~ m/\.a$/) { + if ($line =~ m/\.a$/ || $line =~ m/\.lo$/) { my $libFile = $line; my $path = abs_path($line); my @objs = split ('\n', `cd $tmpdir; ar xv $path`); @@ -401,8 +401,8 @@ foreach $arg (@ARGV) if ($allIsObj) { print $out "$line\n"; } elsif ($realObjs) { - my $libBaseName = basename($libFile, ".a"); - $libBaseName = mktemp($libBaseName . "XXXX") . ".a"; + my($libBaseName, $libDir, $libExt) = fileparse($libFile); + $libBaseName = mktemp($libBaseName . "XXXX") . $libExt; system("cd $tmpdir; ar c $libBaseName $realObjs"); print $out "$tmpdir/$libBaseName\n"; } From 4ad4f6a489623f806df54016eea56bfa8cb0d9b1 Mon Sep 17 00:00:00 2001 From: Aaron Enye Shi Date: Fri, 22 Jun 2018 14:37:19 +0000 Subject: [PATCH 4/7] Add HIP Compute Mode [ROCm/clr commit: c73cd64f5b8bf226bf8d19066119756b067c57bb] --- projects/clr/hipamd/include/hip/hip_runtime_api.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/projects/clr/hipamd/include/hip/hip_runtime_api.h b/projects/clr/hipamd/include/hip/hip_runtime_api.h index e18c17e07b..2ff562cc01 100644 --- a/projects/clr/hipamd/include/hip/hip_runtime_api.h +++ b/projects/clr/hipamd/include/hip/hip_runtime_api.h @@ -293,6 +293,12 @@ typedef enum hipDeviceAttribute_t { hipDeviceAttributeIntegrated, ///< iGPU } hipDeviceAttribute_t; +enum hipComputeMode { + hipComputeModeDefault = 0, + hipComputeModeExclusive = 1, + hipComputeModeProhibited = 2, + hipComputeModeExcusiveProcess = 3 +}; /** * @} From bba741a9135113cd57879c57db41d5cdc51e3e49 Mon Sep 17 00:00:00 2001 From: "Yaxun (Sam) Liu" Date: Mon, 25 Jun 2018 18:12:36 -0400 Subject: [PATCH 5/7] Add workaround to hipcc for build failure in tensorflow due to missing symbol __cpu_model https://github.com/tensorflow/tensorflow/issues/9593 [ROCm/clr commit: 632baba3536fd9c6de09dd696e8baa279fdb6742] --- projects/clr/hipamd/bin/hipcc | 3 +++ 1 file changed, 3 insertions(+) diff --git a/projects/clr/hipamd/bin/hipcc b/projects/clr/hipamd/bin/hipcc index 03f35b27fc..731c9bcc96 100755 --- a/projects/clr/hipamd/bin/hipcc +++ b/projects/clr/hipamd/bin/hipcc @@ -601,6 +601,9 @@ if ($needLDFLAGS and not $compileOnly) { $CMD .= " $HIPLDFLAGS"; } $CMD .= " $toolArgs"; +if ($needLDFLAGS and not $compileOnly and $HIP_PLATFORM eq "clang") { + $CMD .= " -lgcc_s -lgcc"; +} if ($verbose & 0x1) { print "hipcc-cmd: ", $CMD, "\n"; From e6c2e3ee1bdca35d5d1125a863a94e948ae49575 Mon Sep 17 00:00:00 2001 From: Maneesh Gupta Date: Mon, 2 Jul 2018 10:37:20 +0530 Subject: [PATCH 6/7] Update hip-targets.cmake for hip::host & hip::device [ROCm/clr commit: 1978cea4b7db775dfc11ad9d7aaa923a110a4faf] --- .../clr/hipamd/packaging/hip-targets.cmake | 20 ++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/projects/clr/hipamd/packaging/hip-targets.cmake b/projects/clr/hipamd/packaging/hip-targets.cmake index 65370eec9e..5aff2ca1ed 100644 --- a/projects/clr/hipamd/packaging/hip-targets.cmake +++ b/projects/clr/hipamd/packaging/hip-targets.cmake @@ -16,7 +16,7 @@ set(CMAKE_IMPORT_FILE_VERSION 1) set(_targetsDefined) set(_targetsNotDefined) set(_expectedTargets) -foreach(_expectedTarget hip::hip_hcc_static hip::hip_hcc hip::hip_device) +foreach(_expectedTarget hip::hip_hcc_static hip::hip_hcc hip::hip_device hip::host hip::device) list(APPEND _expectedTargets ${_expectedTarget}) if(NOT TARGET ${_expectedTarget}) list(APPEND _targetsNotDefined ${_expectedTarget}) @@ -65,6 +65,24 @@ set_target_properties(hip::hip_device PROPERTIES INTERFACE_SYSTEM_INCLUDE_DIRECTORIES "${_IMPORT_PREFIX}/include;/opt/rocm/hsa/include" ) +# Create imported target hip::host +add_library(hip::host INTERFACE IMPORTED) + +set_target_properties(hip::host PROPERTIES + INTERFACE_LINK_LIBRARIES "hip::hip_hcc" +) + +# Create imported target hip::device +add_library(hip::device INTERFACE IMPORTED) + +set_target_properties(hip::device PROPERTIES + INTERFACE_LINK_LIBRARIES "hip::host;hip::hip_device;hcc::hccrt;hcc::hc_am" +) + +if(CMAKE_VERSION VERSION_LESS 3.0.0) + message(FATAL_ERROR "This file relies on consumers using CMake 3.0.0 or greater.") +endif() + # Load information for each installed configuration. get_filename_component(_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH) file(GLOB CONFIG_FILES "${_DIR}/hip-targets-*.cmake") From 70a7d3961e259761d8853afe4ed738c9ad91eed0 Mon Sep 17 00:00:00 2001 From: Maneesh Gupta Date: Wed, 4 Jul 2018 09:33:51 +0530 Subject: [PATCH 7/7] Update hip_hcc_internal.h Adding missing include for hip_hcc_internal in order to build with HCC [ROCm/clr commit: d372d0eaad08571feaf5f379cc4782ace22a83b9] --- projects/clr/hipamd/src/hip_hcc_internal.h | 1 + 1 file changed, 1 insertion(+) diff --git a/projects/clr/hipamd/src/hip_hcc_internal.h b/projects/clr/hipamd/src/hip_hcc_internal.h index 4008df1574..be257aff4f 100644 --- a/projects/clr/hipamd/src/hip_hcc_internal.h +++ b/projects/clr/hipamd/src/hip_hcc_internal.h @@ -26,6 +26,7 @@ THE SOFTWARE. #include #include #include +#include #include "hsa/hsa_ext_amd.h" #include "hip/hip_runtime.h"