-
Notifications
You must be signed in to change notification settings - Fork 813
-
Hi, is there a code sample for vector dot product, using SYCL esimd intrinsic functions?
Thanks,
D.
Beta Was this translation helpful? Give feedback.
All reactions
Replies: 3 comments 3 replies
-
@mathbird do you mean dp4a intrinsic? There's a test case for that: https://github.com/intel/llvm-test-suite/blob/intel/SYCL/ESIMD/dp4a.cpp
Beta Was this translation helpful? Give feedback.
All reactions
-
I mean this:
let
A=(a_1,a_2,..., a_n)
B=(b_1,b_2,..., b_n)
do the calculation: sum =dot(A, B) = a_1 * b_2 + a_1 * b_2 + ... + a_n * b_n.
I would like to see how ESIMD uses shared local memory in the calculation.
In other words, how to rewrite the following program with SYCL ESIMD:
#include <stdlib.h>
#include <math.h>
#include <stdio.h>
#include <iostream>
#define N 1<<10
int main(int argc, char *argv[] )
{
double *A = new double[N];
double *B = new double[N];
for(int i = 0; i < N; i++){
A[i] = 0.1;
B[i] = 0.2;
}
double sum = 0.0;
for(int i = 0; i < N; i++){
sum += A[i]*B[i];
}
std::cout << " sum =" << sum << std::endl;
delete []A;
delete []B;
return 0;
}
Beta Was this translation helpful? Give feedback.
All reactions
-
Tagging @kbobrovs and @DenisBakhvalov here to help answering the question
Beta Was this translation helpful? Give feedback.
All reactions
-
Looks like you are basically looking how to do a reduction in ESIMD using SLM. Good example is https://github.com/intel/llvm-test-suite/blob/intel/SYCL/ESIMD/histogram_256_slm.cpp, look for slm_init, slm_load, slm_atomic, slm_store.
Beta Was this translation helpful? Give feedback.
All reactions
-
Is SYCL ESMID portable (e.g. NVIDIA GPUs) ?
Is the dp4a example specific to Intel GPUs ?
https://github.com/intel/llvm-test-suite/blob/intel/SYCL/ESIMD/dp4a.cpp
Beta Was this translation helpful? Give feedback.
All reactions
-
@jinz2014, it is not portable to other devices (even Intel CPUs).
It is documented as intel extension: https://github.com/intel/llvm/tree/sycl/sycl/doc/extensions/supported/sycl_ext_intel_esimd which generally means that it won't/can't be supported on HW from other vendors.
And it also explicitly states that this is an interface to Intel GPU HW capabilities:
The main motivation for introducing the "Explicit SIMD" SYCL extension (or simply "ESIMD") is enabling efficient low-level programming for Intel graphics architectures.
Essentially, it is not portable because it almost directly maps to Intel GPU ISA.
Beta Was this translation helpful? Give feedback.