#include <stdio.h>
#include <spu_mfcio.h>

#include <string.h>

#include "iolaos.h"

#include "hello.h"

volatile globals_t globals __attribute__((aligned (16)));

volatile locals_t locals __attribute__((aligned (16)));

int main(unsigned long long speid, addr64_t argp, addr64_t envp)
{
	int my_id, i;

	init_spe(argp, envp, (void*)&globals, sizeof(globals_t), (void*)&locals, sizeof(locals_t));

	my_id = get_my_id();

	printf("Hello %s!\nGreetings from SPE %i!\nData: %i\n", globals.name, my_id, locals.some_data);

	barrier(30);

	if (my_id == 0)
		for (i = 0; i < 16; i++)
			printf("log_id(%i): %i  phys_id(%i): %i\n", i, get_log_id(i), i, get_phys_id(i));

	barrier(30);

	return 0;
}

