forked from parallella/pal
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathp_min.c
39 lines (36 loc) · 778 Bytes
/
p_min.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#include <pal.h>
/**
*
* Finds the minimum value in vector 'a'. Returns the min value and the index
* of the minimum value.
*
* @param a Pointer to input vector
*
* @param c Pointer to output scalar
*
* @param[out] index Pointer to return index of min
*
* @param n Size of 'a' vector.
*
* @param p Number of processor to use (task parallelism)
*
* @param team Team to work with
*
* @return None
*
*/
void p_min_f32(float *a, float *c, int *index, int n, int p, p_team_t team)
{
float min;
int i, pos;
min = *a;
pos = 0;
for (i = 1; i < n; i++) {
if (*(a + i) < min) {
pos = i;
min = *(a + i);
}
}
*c = min;
*index = pos;
}