PandA-2024.02
examples
omp_simd
dotproduct
modified
dotproduct.c
Go to the documentation of this file.
1
/* Parallelizable Dot Product Benchmark
2
*
3
* A.B=A0*B0+A1*B1+A2*B2+A3*B3
4
*
5
*
6
*/
7
8
#define ARRAY_SIZE 6000
9
#define NUMS_OF_ACCEL 8
10
#define OPS_PER_ACCEL ARRAY_SIZE/NUMS_OF_ACCEL
11
12
#include <stdio.h>
13
#include "
dotproduct.h
"
14
15
int
result_array
[
NUMS_OF_ACCEL
];
16
17
// Calculate the values for an entire row
18
int
product
(
int
* inputA,
int
* inputB,
int
startidx,
int
maxidx)
19
{
20
int
i,j;
21
int
result
= 0;
22
for
(i = 0; i <
OPS_PER_ACCEL
; i++){
23
result+= inputA[i]*inputB[i];
24
}
25
return
result
;
26
}
27
28
int
main
(){
29
int
result
=0;
30
int
i;
31
32
#pragma omp simd
33
for
(i=0; i<
NUMS_OF_ACCEL
; i++) {
34
result_array
[i] =
product
(
A_array
,
B_array
, i*
OPS_PER_ACCEL
, (i+1)*OPS_PER_ACCEL);
35
}
36
37
//combining the results
38
for
(i=0; i<
NUMS_OF_ACCEL
; i++) {
39
result +=
result_array
[i];
40
}
41
42
//check final result
43
printf (
"Result: %d\n"
, result);
44
if
(result == 60604032) {
45
printf(
"RESULT: PASS\n"
);
46
return
0;
47
}
else
{
48
printf(
"RESULT: FAIL\n"
);
49
return
1;
50
}
51
}
NUMS_OF_ACCEL
#define NUMS_OF_ACCEL
Definition:
dotproduct.c:9
B_array
int B_array[ARRAY_SIZE]
Definition:
dotproduct.h:2
product
int product(int *inputA, int *inputB, int startidx, int maxidx)
Definition:
dotproduct.c:18
result_array
int result_array[NUMS_OF_ACCEL]
Definition:
dotproduct.c:15
main
int main()
Definition:
dotproduct.c:28
result
int result[SIZE]
Definition:
adpcm.c:800
A_array
int A_array[ARRAY_SIZE]
Definition:
dotproduct.h:1
OPS_PER_ACCEL
#define OPS_PER_ACCEL
Definition:
dotproduct.c:10
dotproduct.h
Generated on Mon Feb 12 2024 13:02:50 for PandA-2024.02 by
1.8.13