pascalabcnet/InstallerSamples/StandardUnits/OpenGL и OpenCL/OpenCL/MatrMlt.cl

29 lines
556 B
Common Lisp
Raw Permalink Normal View History

2021-01-05 14:30:54 +03:00
#pragma OPENCL EXTENSION cl_khr_fp64: enable
2019-05-18 10:24:07 +03:00
2020-08-04 02:26:50 +03:00
__kernel void MatrMltMatr(__global double* A, __global double* B, __global double* C, int W)
2019-05-18 10:24:07 +03:00
{
int cX = get_global_id(0);
int cY = get_global_id(1);
double sum = 0.0;
for (int i=0; i<W; i++)
sum += A[i + cX*W] * B[cY + i*W];
2019-05-18 10:24:07 +03:00
C[cX + cY*W] = sum;
}
2020-08-04 02:26:50 +03:00
__kernel void MatrMltVec(__global double* C, __global double* V1, __global double* V2, int W)
2019-05-18 10:24:07 +03:00
{
int i = get_global_id(0);
double sum = 0.0;
for (int j=0; j<W; j++)
sum += C[j + i*W] * V1[j];
2019-05-18 10:24:07 +03:00
V2[i] = sum;
}