hi,
i was wandering if you could help me with my C++ amp code. I want to parallel the multiplication of vector and matrix. Here is my code
#include <amp.h>
using namespace std;
using namespace concurrency;
int _tmain(int argc, _TCHAR* argv[])
int n;
cin>> n;
double **A = new double*[n];
for(int i = 0; i < n; ++i) {
A[i] = new double[n];
}
for (int i = 0; i < n ; ++ i)
for (int j = 0; j < n; ++ j){
A[i][j]=rand()%100;
A[j][i]=A[i][j];
}
for( int i=0; i < n; i++)
x[i]=0;
double *ri = new double[n];
for( int i=0; i < n; i++)
ri[i]=0;
double *ri1 = new double[n];
array_view<const double, 2> a(n, n, A);
array_view<const double, 1> X(n, x);
array_view<double, 1> RI(n, ri);
RI.discard_data();
parallel_for_each(
RI.extent,
[=] (index<1> idx) restrict(amp) {
int y = idx[0];
double result = 0.0f;
for (int k=0; k<n; k++) {
result += a(y, k) * X(k); }
RI[idx] = result;
});
RI.synchronize();
could you please help me and tell me why it is not working? I try to find a solution. I have C2228 and C2338 errors.
Thank you in advance!
Regards,
Bartosz