Initial commit.

This commit is contained in:
2017-10-26 19:57:24 +02:00
commit 9ce8b5485d
1090 changed files with 47036 additions and 0 deletions
+16
View File
@@ -0,0 +1,16 @@
########################################################################
# Target
########################################################################
DIRS = src/spu src/ppu
########################################################################
# buildutils/make.footer
########################################################################
ifdef CELL_TOP
include $(CELL_TOP)/buildutils/make.footer
else
include /opt/cell/sdk/buildutils/make.footer
endif
+26
View File
@@ -0,0 +1,26 @@
########################################################################
# Target
########################################################################
PROGRAM_ppu64 = ../../simple_saite2
########################################################################
# Local Defines
########################################################################
INCLUDE = -I../../../../include/ppu
LDFLAGS = -L../../../../lib/ppu
IMPORTS = -lmoc_ppu -lspe2 ../spu/simple_saite_spu.a
########################################################################
# buildutils/make.footer
########################################################################
ifdef CELL_TOP
include $(CELL_TOP)/buildutils/make.footer
else
include /opt/cell/sdk/buildutils/make.footer
endif
+150
View File
@@ -0,0 +1,150 @@
#include <moc.h>
#include <stdlib.h>
#include <string.h>
#include <malloc_align.h>
extern spe_program_handle_t simple_saite_spu;
#define DELTA_X 1
#define DELTA_T 1
#define ITERATIONS 48000
#define THREAD_COUNT 6
#define ELEMENT_COUNT 1200*6+2
void populate_vector(double* vector)
{
int t;
for (t = 0; t < ELEMENT_COUNT; t++)
vector[t] = 0;
vector[ELEMENT_COUNT / 2 - 2 ]= 0.2;
vector[ELEMENT_COUNT/2-1] = 0.5;
vector[ELEMENT_COUNT/2] = 0.8;
vector[ELEMENT_COUNT/2+1] = 0.5;
vector[ELEMENT_COUNT/2+2] = 0.2;
}
void process_result(double* vector)
{
}
int main()
{
int t, t2, rank, size, rl, mspu, aspu, temp1;
char proc[4];
MOC_Status moc_status;
double start, ende;
uint64_t test;
int thread_count, ept1, ept2;
double saite1[ELEMENT_COUNT] __attribute__((__aligned__(16)));
double saite2[ELEMENT_COUNT] __attribute__((__aligned__(16)));
double saite3[ELEMENT_COUNT] __attribute__((__aligned__(16)));
char param[16] __attribute__((__aligned__(16)));
if (MOC_Get_max_spu_count(&mspu))
{
printf("An error occured during MOC_Get_max_spu_count\n");
return 0;
}
if (MOC_Get_avail_spu_count(&aspu))
{
printf("An error occured during MOC_Get_avail_spu_count\n");
return 0;
}
printf("\nThere are %i of %i SPUs available.\n\n", aspu, mspu);
#if (THREAD_COUNT == 0)
for (t = 0; t < aspu; t++)
MOC_Add_spu_thread ( &simple_saite_spu, NULL );
thread_count = aspu;
#else
for (t = 0; t < THREAD_COUNT; t++)
MOC_Add_spu_thread(&simple_saite_spu, NULL);
thread_count = THREAD_COUNT;
#endif
populate_vector(saite1);
populate_vector(saite2);
thread_count = aspu;
ept1 = (ELEMENT_COUNT - 2) / thread_count;
if ((ELEMENT_COUNT - 2) % thread_count != 0)
{
ept1++;
ept2 = (ELEMENT_COUNT - 2) - thread_count * ept1;
}
else
ept2 = 0;
MOC_Init(NULL, NULL);
MOC_Comm_rank(MOC_COMM_WORLD, &rank);
MOC_Comm_size(MOC_COMM_WORLD, &size);
MOC_Get_processor_name(proc, &rl);
printf("start\n");
start = MOC_Wtime();
temp1 = 0;
for (t = 1; t < thread_count + 1; t++)
{
*((int*) (param)) = ITERATIONS;
*((int*) (param + 4)) = DELTA_X;
*((int*) (param + 8)) = DELTA_T;
if (t == thread_count && ept2 != 0)
{
*((int*) (param + 12)) = ept2;
test = (uint64_t) saite3;
MOC_Send(&test, 8, MOC_BYTE, t, 0, MOC_COMM_WORLD);
test = (uint64_t) saite1;
MOC_Send(&test, 8, MOC_BYTE, t, 0, MOC_COMM_WORLD);
test = (uint64_t) saite2;
MOC_Send(&test, 8, MOC_BYTE, t, 0, MOC_COMM_WORLD);
MOC_Send(param, 16, MOC_BYTE, t, 0, MOC_COMM_WORLD);
MOC_Send(saite1 + temp1, ept2 + 2, MOC_DOUBLE, t, 1, MOC_COMM_WORLD);
MOC_Send(saite2 + temp1, ept2 + 2, MOC_DOUBLE, t, 1, MOC_COMM_WORLD);
}
else
{
*((int*) (param + 12)) = ept1;
test = (uint64_t) saite3;
MOC_Send(&test, 8, MOC_BYTE, t, 0, MOC_COMM_WORLD);
test = (uint64_t) saite1;
MOC_Send(&test, 8, MOC_BYTE, t, 0, MOC_COMM_WORLD);
test = (uint64_t) saite2;
MOC_Send(&test, 8, MOC_BYTE, t, 0, MOC_COMM_WORLD);
MOC_Send(param, 16, MOC_BYTE, t, 0, MOC_COMM_WORLD);
MOC_Send(saite1 + temp1, ept1 + 2, MOC_DOUBLE, t, 1, MOC_COMM_WORLD);
MOC_Send(saite2 + temp1, ept1 + 2, MOC_DOUBLE, t, 1, MOC_COMM_WORLD);
}
temp1 += ept1;
}
for (t2 = 0; t2 < ITERATIONS; t2++)
{
//MOC_Barrier(MOC_COMM_WORLD);
/**for (t = 1; t < thread_count+1; t++)
{
int temp_count;
MOC_Probe (t, 2, MOC_COMM_WORLD, &moc_status);
MOC_Get_count (&moc_status, MOC_DOUBLE, &temp_count);
temp1 = (moc_status.MOC_SOURCE-1)*ept1;
MOC_Recv (saite3+temp1, temp_count, MOC_DOUBLE, moc_status.MOC_SOURCE,
2, MOC_COMM_WORLD, &moc_status);
}**/
MOC_Barrier(MOC_COMM_WORLD);
process_result(saite3);
}
ende = MOC_Wtime();
MOC_Finalize();
printf("ende ( %lf s)\n", ende - start);
return 0;
}
+25
View File
@@ -0,0 +1,25 @@
########################################################################
# Target
########################################################################
PROGRAMS_spu := simple_saite_spu
LIBRARY_embed64 := simple_saite_spu.a
########################################################################
# Local Defines
########################################################################
INCLUDE = -I../../../../include/spu
LDFLAGS = -L../../../../lib/spu
IMPORTS = -lmoc_spu
########################################################################
# buildutils/make.footer
########################################################################
ifdef CELL_TOP
include $(CELL_TOP)/buildutils/make.footer
else
include /opt/cell/sdk/buildutils/make.footer
endif
+132
View File
@@ -0,0 +1,132 @@
#include <moc.h>
#include <stdio.h>
#include <malloc_align.h>
#include <math.h>
void simulate(double *vector1, double *vector2, double *vector3, double dx,
double dt, double cq, double delta, int e_count)
{
double temp1, temp2;
int x = 1;
for (x = 1; x < e_count + 1; x++)
{
temp1 = 2* vector2 [x] + vector1[x] * (delta * dt - 1);
temp2 = pow(dt / dx, 2) * cq * (vector2[x + 1] - 2* vector2 [x]
+ vector2[x - 1]);
vector3[x] = (temp1 + temp2) / (1 + delta * dt);
}
}
int main()
{
int t, rank, size, rl, err, errlen;
char proc[4];
MOC_Status moc_status;
MOC_Request moc_req;
char error_msg[255];
double *saite1, *saite2, *saite3, *pdtemp;
double temp_double __attribute__((__aligned__(16)));
char param[16] __attribute__((__aligned__(16)));
int iterations, delta_x, delta_t, e_count;
uint64_t ea_saite1 __attribute__((__aligned__(16)));
uint64_t ea_saite2 __attribute__((__aligned__(16)));
uint64_t ea_saite3 __attribute__((__aligned__(16)));
MOC_Init(0, 0, NULL);
MOC_Comm_rank(MOC_COMM_WORLD, &rank);
MOC_Comm_size(MOC_COMM_WORLD, &size);
MOC_Get_processor_name(proc, &rl);
err = MOC_Recv(&ea_saite3, 8, MOC_BYTE, 0, 0, MOC_COMM_WORLD, &moc_status);
err = MOC_Recv(&ea_saite1, 8, MOC_BYTE, 0, 0, MOC_COMM_WORLD, &moc_status);
err = MOC_Recv(&ea_saite2, 8, MOC_BYTE, 0, 0, MOC_COMM_WORLD, &moc_status);
if (err)
{
MOC_Error_string(err, error_msg, &errlen);
printf("%i: %s\n", rank, error_msg);
}
err = MOC_Recv(param, 16, MOC_BYTE, 0, 0, MOC_COMM_WORLD, &moc_status);
if (err)
{
MOC_Error_string(err, error_msg, &errlen);
printf("%i: %s\n", rank, error_msg);
}
iterations = *((int*) (param));
delta_x = *((int*) (param + 4));
delta_t = *((int*) (param + 8));
e_count = *((int*) (param + 12));
saite1 = _malloc_align((e_count + 2) * sizeof(double), 4);
saite2 = _malloc_align((e_count + 2) * sizeof(double), 4);
saite3 = _malloc_align((e_count + 2) * sizeof(double), 4);
MOC_Recv(saite1, e_count + 2, MOC_DOUBLE, 0, 1, MOC_COMM_WORLD, &moc_status);
MOC_Recv(saite2, e_count + 2, MOC_DOUBLE, 0, 1, MOC_COMM_WORLD, &moc_status);
for (t = 0; t < iterations; t++)
{
//MOC_Barrier(MOC_COMM_WORLD);
/**err = MOC_Get_data (saite1, ea_saite1, e_count+2, MOC_DOUBLE);
if (err)
{
MOC_Error_string (err, error_msg, &errlen);
printf("%i: %s\n", rank, error_msg);
}
err = MOC_Get_data (saite2, ea_saite2, e_count+2, MOC_DOUBLE);
if (err)
{
MOC_Error_string (err, error_msg, &errlen);
printf("%i: %s\n", rank, error_msg);
}**/
simulate(saite1, saite2, saite3, delta_x, delta_t, 0.9, 0.01, e_count);
err = MOC_IPut_data(saite3, ea_saite3, e_count + 2, MOC_DOUBLE,
&moc_req);
if (err)
{
MOC_Error_string(err, error_msg, &errlen);
printf("%i: %s\n", rank, error_msg);
}
if (rank > 1)
{
temp_double = saite3[1];
MOC_Send(&temp_double, 1, MOC_DOUBLE, rank - 1, 3, MOC_COMM_WORLD);
}
if (rank < size - 1)
{
temp_double = saite3[e_count];
MOC_Send(&temp_double, 1, MOC_DOUBLE, rank + 1, 3, MOC_COMM_WORLD);
}
if (rank > 1)
{
MOC_Recv(&temp_double, 1, MOC_DOUBLE, rank - 1, 3, MOC_COMM_WORLD,
&moc_status);
saite3[0] = temp_double;
}
if (rank < size - 1)
{
MOC_Recv(&temp_double, 1, MOC_DOUBLE, rank + 1, 3, MOC_COMM_WORLD,
&moc_status);
saite3[e_count + 1] = temp_double;
}
err = MOC_Wait(&moc_req, &moc_status);
if (err)
{
MOC_Error_string(err, error_msg, &errlen);
printf("%i: %s\n", rank, error_msg);
}
MOC_Barrier(MOC_COMM_WORLD);
pdtemp = saite1;
saite1 = saite2;
saite2 = saite3;
saite3 = pdtemp;
}
MOC_Finalize();
return 0;
}