HIP icon indicating copy to clipboard operation
HIP copied to clipboard

std::exclusive_scan is not supported by hipcc

Open ipdemes opened this issue 2 years ago • 2 comments

It seems like std::exclusive scan is not supported by hip compiler. I get an error like:

 error: no member named 'exclusive_scan' in namespace 'std'

Reproducer: add following diff to the vectorAdd example from HIP-examples:

diff --git a/vectorAdd/vectoradd_hip.cpp b/vectorAdd/vectoradd_hip.cpp
index 854ef37..55648da 100644
--- a/vectorAdd/vectoradd_hip.cpp
+++ b/vectorAdd/vectoradd_hip.cpp
@@ -24,6 +24,10 @@ THE SOFTWARE.
 #include <algorithm>
 #include <stdlib.h>
 #include<iostream>
+#include <functional>
+#include <numeric>
+#include <vector>
+
 #include "hip/hip_runtime.h"
 
 
@@ -92,6 +96,12 @@ int main() {
 
   cout << "hip Device prop succeeded " << endl ;
 
+  std::vector<int> data {3, 1, 4, 1, 5, 9, 2, 6};
+  std::vector<int> off;
+  off.resize(data.size());
+  std::exclusive_scan(data.begin(), data.end(),
+                     off.begin(),
+                     0);
 
   int i;
   int errors;

HIP compiler: HIP version: 4.2.21155-37cb3a34 clang version 12.0.0 (https://github.com/RadeonOpenCompute/llvm-project roc-4.2.0 21161 b204d7f0cae65b6cd4446eec50fc1fb675d582af) Target: x86_64-unknown-linux-gnu Thread model: posix InstalledDir: /opt/rocm-4.2.0/llvm/bin

ipdemes avatar Sep 20 '21 21:09 ipdemes

hipcc defaults to passing -std=c++11 to clang. And the Makefile for the vectorAdd sample does not pass any extra flags to hipcc. You would need to modify the Makefile to pass the right flags.

mangupta avatar Sep 22 '21 14:09 mangupta

I seem to be hitting the same error with amdclang++ 14.0.0. The same code compiles without error with clang 14.0.0 (https://godbolt.org/z/4fdMhY51f).

$ amdclang++ -std=c++17 scan.cpp -o scan
scan.cpp:8:8: error: no member named 'exclusive_scan' in namespace 'std'
  std::exclusive_scan(data.begin(), data.end(), off.begin(), 0);
  ~~~~~^
1 error generated.

$ amdclang++ --version
AMD clang version 14.0.0 (https://github.com/RadeonOpenCompute/llvm-project roc-5.2.0 22204 50d6d5d5b608d2abd6af44314abc6ad20036af3b)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /opt/rocm-5.2.0/llvm/bin

$ cat scan.cpp 
#include <numeric>
#include <vector>
 
int main()
{
  std::vector<int> data {3, 1, 4, 1, 5, 9, 2, 6};
  std::vector<int> off(data.size());
  std::exclusive_scan(data.begin(), data.end(), off.begin(), 0);
}

cwsmith avatar Aug 18 '22 20:08 cwsmith

@ipdemes Is this still an issue for you? If not, please close ticket. Thanks!

ppanchad-amd avatar Apr 02 '24 20:04 ppanchad-amd