forked from RipleyTom/SpuTest
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_mfc64.c
96 lines (80 loc) · 2.14 KB
/
test_mfc64.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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <cell/spurs.h>
#include <cell/atomic.h>
#include "spurs_helpers.h"
#include "globals.h"
#include "shared_defines.h"
extern const CellSpursTaskBinInfo _binary_task_task_mfc64_elf_taskbininfo;
static uint64_t atomic_counter __attribute__((aligned(128)));
void ppu_mfc64_entry(uint64_t arg)
{
for (unsigned long counter = 0; counter < NUM_INCREMENTS; counter++)
{
cellAtomicIncr64(&atomic_counter);
}
sys_ppu_thread_exit(0);
}
int test_mfc64(CellSpurs2 *spurs2, unsigned int num_spu, unsigned int num_ppu)
{
int ret;
CellSpursTaskset2 *taskset;
ret = initialize_taskset(spurs2, &taskset, (uint64_t)&atomic_counter);
if (ret != 0)
{
printf("Error initializing taskset: 0x%x\n", ret);
return ret;
}
atomic_counter = 0;
CellSpursTaskId tids[num_spu];
CellSpursTaskArgument args[num_spu];
void *ctx[num_spu];
for (int index = 0; index < num_spu; index++)
{
ctx[index] = memalign(128, _binary_task_task_mfc64_elf_taskbininfo.sizeContext);
ret = cellSpursCreateTask2WithBinInfo(taskset, &tids[index], &_binary_task_task_mfc64_elf_taskbininfo, &args[index], ctx[index], NULL, NULL);
if (ret != 0)
{
printf("Error cellSpursCreateTask2WithBinInfo: 0x%x\n", ret);
return ret;
}
}
sys_ppu_thread_t ppu_ids[num_ppu];
for (int index = 0; index < num_ppu; index++)
{
ret = sys_ppu_thread_create(&ppu_ids[index], ppu_mfc64_entry, 0, 1000, 0x1000, SYS_PPU_THREAD_CREATE_JOINABLE, "PPU MFC 64 Bit");
if (ret != 0)
{
printf("Error sys_ppu_thread_create: 0x%x\n", ret);
return ret;
}
}
uint64_t ppu_exit_code;
for (int index = 0; index < num_ppu; index++)
{
ret = sys_ppu_thread_join(ppu_ids[index], &ppu_exit_code);
if (ret != 0)
{
printf("Error sys_ppu_thread_join: 0x%x\n", ret);
return ret;
}
}
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]);
}
if (verbose)
{
printf("Atomic counter is %u\n", atomic_counter);
}
free_taskset(taskset);
return 0;
}