Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Victor_E_1
Beginner
232 Views

Sycl 2020 on devcloud?

How much of SYCL 2020 is availabe on the devcloud?

 

reduct1d.cxx:45:38: error: no member named 'reducer' in namespace 'cl::sycl'
        auto scalar_accessor = sycl::reducer
                               ~~~~~~^
0 Kudos
7 Replies
AbhishekD_Intel
Moderator
210 Views

Hi,


Thanks for reaching out to us.

If you want more details regarding the SYCL specification and DPC++, then please follow the below link it will give you complete details.

https://spec.oneapi.com/versions/latest/elements/dpcpp/source/index.html#extensions-table

From the error log, it's hard to come up with a conclusion regarding your issue, so if you have any issue regarding the reducer class which you are trying to use or reduction function please send us a small reproducer of your code so that we will get more insight into your issue.


Warm Regards,

Abhishek


Victor_E_1
Beginner
206 Views

Thanks for that table. That is useful. Here is my code and error message:

 

dpcpp -c reductscalar.cxx  -std=c++17 -O2 -g
reductscalar.cxx:42:11: error: no member named 'reduction' in namespace 'cl::sycl'
    sycl::reduction( sum_array, static_cast<float>(0.), std::plus<float>() );
    ~~~~~~^
1 error generated.



#include <CL/sycl.hpp>
#include <iostream>
#include <vector>
using std::vector;
#include <cstdio>

using namespace cl;

int main() {

  sycl::cpu_selector selector;
  sycl::queue myqueue(selector);

  auto ctx = myqueue.get_context();
  auto dev = myqueue.get_device();

  int array_size; std::cin >> array_size;
  float *shared_array = (float*) malloc_shared( array_size*sizeof(float),dev,ctx );
  float *sum_array = (float*) malloc_shared( sizeof(float),dev,ctx );
  float check_sum = 0.;
  for (int i=0; i<array_size; i++) {
    shared_array[i] = static_cast<float>(i);
    check_sum += shared_array[i];
  }

  sycl::range<1> array_range{static_cast<size_t>(array_size)};
  //codesnippet syclsumreduct
  auto reduce_to_sum =
    sycl::reduction( sum_array, static_cast<float>(0.), std::plus<float>() );
  myqueue.parallel_for// parallel_for<reduction_kernel<T,BinaryOp,__LINE__>>
    ( array_range,    // sycl::range<1>(input_size),
      reduce_to_sum,  // sycl::reduction(output, identity, op),
      [=] (sycl::id<1> idx, auto& reducer) { // type of reducer is impl-dependent, so use auto
      reducer.combine(shared_array[idx[0]]); //(input[idx[0]]);
      //reducer += shared_array[idx[0]]; // see line 216: add_reducer += input0[idx[0]];
    } ).wait();
  //codesnippet end

  printf("Sum= %e, s/b=%e\n",sum_array[0],check_sum);

  return 0;
}
AbhishekD_Intel
Moderator
190 Views

Hi,


Thanks for the code snippet. We can see that you are trying to access reduction from sycl namespace, but the reduction functionality is present in a different namespace.

As you are trying to run your code on the Devcloud the SYCL_COMPILER_VERSION is greater than 20200827, so try using sycl::ONEAPI::reduction(....), this will not give the error on reduction function.

There is one more issue with your code, you are just using range with index with a reduction, but the reduction should be used with nd_range and nd_item in the data-parallel kernel.

You can follow the below syntax for reference.

using namespace sycl;

handler.parallel_for(

nd_range<1>{global_range, local_range},

ONEAPI::reduction(sum, plus<>()),

[=](nd_item<1> it, auto& sum) {

int i = it.get_global_id(0);

sum += data[i];

});


For more details please refer to the below OneAPI Samples (GSimulation.cpp)

https://github.com/oneapi-src/oneAPI-samples/tree/master/DirectProgramming/DPC%2B%2B/N-BodyMethods/N...


Hope the provided details will solve your issue.



Warm Regards,

Abhishek


AbhishekD_Intel
Moderator
152 Views

Hi,

Please give us an update on the provided details and do let us know if it had solved your issue.



Warm Regards,

Abhishek


Victor_E_1
Beginner
145 Views

Abhishek,

the Sycl 2020 standard just came out, so I'm reluctant to use solutions that are based on Intel-only namespaces.

What are the plans for implementing the 2020 standard?

 

Victor.

AbhishekD_Intel
Moderator
97 Views

Hi Victor,


I will forward your question to the subject matter expert for more details regarding the implementation of the latest SYCL standard.

Please expect a reply in this same thread.


Warm Regards,

Abhishek


Varsha_M_Intel
Employee
37 Views

some of the SYCL2020 features are already in DPC++ Compiler initial release and we will continue to add support for more in future releases. A comprehensive list will be released soon.