-
Notifications
You must be signed in to change notification settings - Fork 2
/
test_spu_inst.c
67 lines (55 loc) · 1.3 KB
/
test_spu_inst.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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <cell/spurs.h>
#include <cell/atomic.h>
#include "spurs_helpers.h"
#include "globals.h"
#define NUM_SPU 6
int test_spu_inst(CellSpurs2 *spurs2, const CellSpursTaskBinInfo *program)
{
int ret;
CellSpursTaskset2 *taskset;
ret = initialize_taskset(spurs2, &taskset, 0);
if (ret != 0)
{
printf("Error initializing taskset: 0x%x\n", ret);
return ret;
}
CellSpursTaskId tids[NUM_SPU];
CellSpursTaskArgument args[NUM_SPU];
void *ctx[NUM_SPU];
for (int index = 0; index < NUM_SPU; index++)
{
ctx[index] = memalign(128, program->sizeContext);
for (int subdex = 0; subdex < 4; subdex++)
{
args[index].u32[subdex] = (index * 8) + subdex;
}
ret = cellSpursCreateTask2WithBinInfo(taskset, &tids[index], program, &args[index], ctx[index], NULL, NULL);
if (ret != 0)
{
printf("Error cellSpursCreateTask2WithBinInfo: 0x%x\n", ret);
return ret;
}
}
uint64_t sum = 0;
int exit_code;
for (int index = 0; index < NUM_SPU; index++)
{
ret = cellSpursJoinTask2(taskset, tids[index], &exit_code);
if (ret != 0)
{
printf("Error cellSpursJoinTask2: 0x%x\n", ret);
return ret;
}
free(ctx[index]);
sum += (uint32_t)exit_code;
}
if (verbose)
{
printf("Sum: %llu\n", sum);
}
free_taskset(taskset);
return 0;
}