From 1dcdfc93f135a6fe9570f80cd909f76881bed0f5 Mon Sep 17 00:00:00 2001 From: Aditya Atluri Date: Wed, 6 Apr 2016 14:18:51 -0500 Subject: [PATCH 1/4] Added feature for cross-compilation and seperated hcc api from hip api --- bin/hipcc | 10 ++++++++-- include/hcc.h | 8 ++++++++ include/hcc_detail/hcc_acc.h | 20 ++++++++++++++++++++ include/hcc_detail/hip_runtime_api.h | 14 -------------- tests/src/hipHcc.cpp | 2 +- 5 files changed, 37 insertions(+), 17 deletions(-) create mode 100644 include/hcc.h create mode 100644 include/hcc_detail/hcc_acc.h diff --git a/bin/hipcc b/bin/hipcc index 289574d8e5..e4d203f685 100755 --- a/bin/hipcc +++ b/bin/hipcc @@ -40,7 +40,6 @@ $CODEXL_PATH = $ENV{'CODEXL_PATH'}; $CODEXL_PATH = "/opt/AMD/CodeXL" unless defined $CODEXL_PATH; $marker_path = "$CODEXL_PATH/SDK/AMDTActivityLogger"; - #--- #HIP_PLATFORM controls whether to use NVCC or HCC for compilation: $HIP_PLATFORM=$ENV{'HIP_PLATFORM'}; @@ -67,7 +66,7 @@ if ($HIP_PLATFORM eq "hcc") { # HCC* may be used to compile src/hip_hcc.o (and also feed the HIPCXXFLAGS below) $HCC = "$HCC_HOME/bin/hcc"; - $HCCFLAGS = " -hc -I$HCC_HOME/include -stdlib=libc++"; + $HCCFLAGS = " -hc -I$HCC_HOME/include "; $HIPCC=$HCC; $HIPCXXFLAGS = $HCCFLAGS; @@ -144,6 +143,13 @@ foreach $arg (@ARGV) $needLDFLAGS = 1; } + if($arg eq '-stdlib=libstdc++') + { + $HIPCXXFLAGS .= " -stdlib=libstdc++"; + }else + { + $HIPCXXFLAGS .= " -stdlib=libc++"; + } if ($arg =~ m/^-/) { # options start with - diff --git a/include/hcc.h b/include/hcc.h new file mode 100644 index 0000000000..9766e95935 --- /dev/null +++ b/include/hcc.h @@ -0,0 +1,8 @@ +#ifndef HCC_H +#define HCC_H + +#if defined(__HIP_PLATFORM_HCC__) && !defined (__HIP_PLATFORM_NVCC__) +#include +#endif + +#endif diff --git a/include/hcc_detail/hcc_acc.h b/include/hcc_detail/hcc_acc.h new file mode 100644 index 0000000000..c66b340579 --- /dev/null +++ b/include/hcc_detail/hcc_acc.h @@ -0,0 +1,20 @@ +#ifndef HCC_ACC_H +#define HCC_ACC_H +#include "hip_runtime_api.h" + +#if __cplusplus +#ifdef __HCC__ +#include +/** + * @brief Return hc::accelerator associated with the specified deviceId + */ +hipError_t hipHccGetAccelerator(int deviceId, hc::accelerator *acc); + +/** + * @brief Return hc::accelerator_view associated with the specified stream + */ +hipError_t hipHccGetAcceleratorView(hipStream_t stream, hc::accelerator_view **av); +#endif +#endif + +#endif diff --git a/include/hcc_detail/hip_runtime_api.h b/include/hcc_detail/hip_runtime_api.h index eecab9abc3..b5fdb312a4 100644 --- a/include/hcc_detail/hip_runtime_api.h +++ b/include/hcc_detail/hip_runtime_api.h @@ -1041,20 +1041,6 @@ hipError_t hipDriverGetVersion(int *driverVersion) ; * @endcode * */ -#if __cplusplus -#ifdef __HCC__ -#include -/** - * @brief Return hc::accelerator associated with the specified deviceId - */ -hipError_t hipHccGetAccelerator(int deviceId, hc::accelerator *acc); - -/** - * @brief Return hc::accelerator_view associated with the specified stream - */ -hipError_t hipHccGetAcceleratorView(hipStream_t stream, hc::accelerator_view **av); -#endif -#endif // end-group HCC_Specific /** diff --git a/tests/src/hipHcc.cpp b/tests/src/hipHcc.cpp index b3580db660..e3740fa27b 100644 --- a/tests/src/hipHcc.cpp +++ b/tests/src/hipHcc.cpp @@ -24,7 +24,7 @@ THE SOFTWARE. #include #include #include - +#include #include "test_common.h" #define CHECK(error) \ From 3304092b4958000d915d96f4cb61bf381028cd23 Mon Sep 17 00:00:00 2001 From: Aditya Atluri Date: Wed, 6 Apr 2016 14:50:27 -0500 Subject: [PATCH 2/4] Corrected corner cases --- bin/hipcc | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/bin/hipcc b/bin/hipcc index e4d203f685..14a6cfe2f2 100755 --- a/bin/hipcc +++ b/bin/hipcc @@ -55,7 +55,7 @@ if ($verbose & 0x2) { print ("CUDA_PATH=$CUDA_PATH\n"); } - +$enablestdcpplib = 0; if ($HIP_PLATFORM eq "hcc") { $HSA_PATH=$ENV{'HSA_PATH'}; @@ -143,12 +143,10 @@ foreach $arg (@ARGV) $needLDFLAGS = 1; } - if($arg eq '-stdlib=libstdc++') + if($arg eq '-stdlib=libstdc++' and $enablestdcpplib eq 0) { $HIPCXXFLAGS .= " -stdlib=libstdc++"; - }else - { - $HIPCXXFLAGS .= " -stdlib=libc++"; + $enablestdcpplib = 1; } if ($arg =~ m/^-/) { @@ -189,6 +187,11 @@ if ($hasCU and $HIP_PLATFORM eq 'hcc') { $HIPCXXFLAGS .= " -x c++"; } +if ($enablestdcpplib eq 0) +{ + $HIPCXXFLAGS .= " -stdlib=libc++"; +} + if ($needHipHcc) { $HIP_USE_SHARED_LIBRARY = $ENV{'HIP_USE_SHARED_LIBRARY'}; $HIP_USE_SHARED_LIBRARY = 0 unless defined $HIP_USE_SHARED_LIBRARY; From 1e6b79ea6482910fb0f0140d8f73f25dfe9ff799 Mon Sep 17 00:00:00 2001 From: Maneesh Gupta Date: Thu, 7 Apr 2016 10:48:16 +0530 Subject: [PATCH 3/4] Fix broken CUDA path in hipcc --- bin/hipcc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/hipcc b/bin/hipcc index 14a6cfe2f2..fef4175e66 100755 --- a/bin/hipcc +++ b/bin/hipcc @@ -187,7 +187,7 @@ if ($hasCU and $HIP_PLATFORM eq 'hcc') { $HIPCXXFLAGS .= " -x c++"; } -if ($enablestdcpplib eq 0) +if ($enablestdcpplib eq 0 and $HIP_PLATFORM eq 'hcc') { $HIPCXXFLAGS .= " -stdlib=libc++"; } From 4b2c5976cea7bfcde4d4803da70beff66f0579af Mon Sep 17 00:00:00 2001 From: pensun Date: Thu, 7 Apr 2016 09:46:00 -0500 Subject: [PATCH 4/4] clean up unused comments --- src/hip_hcc.cpp | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/src/hip_hcc.cpp b/src/hip_hcc.cpp index 6c80b84e0e..3c087467d7 100644 --- a/src/hip_hcc.cpp +++ b/src/hip_hcc.cpp @@ -137,7 +137,7 @@ ihipStream_t::ihipStream_t(unsigned device_index, hc::accelerator_view av, unsig //--- ihipStream_t::~ihipStream_t() -{ +{ } @@ -899,7 +899,6 @@ void ihipInit() for (int i=0; i