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 = ../../pi
########################################################################
# Local Defines
########################################################################
INCLUDE = -I../../../../include/ppu
LDFLAGS = -L../../../../lib/ppu
IMPORTS = -lmoc_ppu -lspe2 ../spu/pi_spu.a
########################################################################
# buildutils/make.footer
########################################################################
ifdef CELL_TOP
include $(CELL_TOP)/buildutils/make.footer
else
include /opt/cell/sdk/buildutils/make.footer
endif
+81
View File
@@ -0,0 +1,81 @@
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <moc.h>
//#include <../moc_status.h>
#define MASTER 0
extern spe_program_handle_t pi_spu;
int main()
{
MOC_Status mpStatus;
int nNP, nRank, mspu, aspu;
double ldResult = 0.0;
double ldReceiveResult = 0.0;
double step;
double i, lFrom, lTo;
double dStart, dEnd;
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);
MOC_Add_spu_thread ( &pi_spu, NULL );
MOC_Add_spu_thread ( &pi_spu, NULL );
MOC_Add_spu_thread ( &pi_spu, NULL );
MOC_Add_spu_thread ( &pi_spu, NULL );
MOC_Add_spu_thread ( &pi_spu, NULL );
MOC_Add_spu_thread ( &pi_spu, NULL );
MOC_Set_buffer_size ( 500000);
MOC_Init(NULL, NULL);
MOC_Comm_size(MOC_COMM_WORLD, &nNP); /*get #(processors)*/
MOC_Comm_rank(MOC_COMM_WORLD, &nRank);/*find rank of this process*/
printf("[RANK-%d] processes: %d\n", nRank, nNP);
dStart = MOC_Wtime();
// calculate range
lFrom = (1.0*nRank)/nNP;
lTo = lFrom + 1.0/nNP;
step = 0.0000001;
// calculate pi
for (i = lFrom; i <= lTo; i+=step)
{
ldResult += step * 4./(1 + ((long double)i*i));
}
dEnd = MOC_Wtime();
if (nRank==MASTER)
{
// receive results from slaves
for (i = 1; i < nNP; i++)
{
MOC_Recv(&ldReceiveResult, sizeof(double), MOC_BYTE,MOC_ANY_SOURCE, MOC_ANY_TAG, MOC_COMM_WORLD, &mpStatus);
ldResult += ldReceiveResult;
}
dEnd = MOC_Wtime();
printf("[RANK-%d] result %1.20f in %2.8f sec\r\n", nRank, ldResult, (dEnd-dStart));
}
MOC_Finalize(); // close MPI application
return 0;
}
+29
View File
@@ -0,0 +1,29 @@
########################################################################
# Target
########################################################################
PROGRAMS_spu := pi_spu
LIBRARY_embed64 := pi_spu.a
########################################################################
# Local Defines
########################################################################
INCLUDE += -I../../../../include/spu
LDFLAGS += -L../../../../lib/spu
IMPORTS += -lmoc_spu
# Only necessary if the SPU-Decrementer is used as Time-Source for the SPUs
LDFLAGS += -L/opt/cell/sysroot/opt/cell/sdk/prototype/usr/spu/lib
#IMPORTS += -lsputimer
########################################################################
# buildutils/make.footer
########################################################################
ifdef CELL_TOP
include $(CELL_TOP)/buildutils/make.footer
else
include /opt/cell/sdk/buildutils/make.footer
endif
+47
View File
@@ -0,0 +1,47 @@
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <moc.h>
//#include <../moc_status.h>
#define MASTER 0
int main()
{
int nNP, nRank;
double ldResult = 0.0;
double step;
double i, lFrom, lTo;
double dStart, dEnd;
MOC_Init( 0, 0, NULL);
MOC_Comm_size(MOC_COMM_WORLD, &nNP); // get #(processes)
MOC_Comm_rank(MOC_COMM_WORLD, &nRank); // find rank of this process
dStart = MOC_Wtime();
// calculate range
lFrom = (1.0*nRank)/nNP;
lTo = lFrom + 1.0/nNP;
step = 0.0000001;
ldResult = 0.0;
// calculate pi
for (i = lFrom; i <= lTo; i+=step)
ldResult += step * 4./(1 + ((long double)i*i));
dEnd = MOC_Wtime();
if(nRank != MASTER)
{
// send result to master
MOC_Send(&ldResult, sizeof(double), MOC_BYTE, MASTER, 1,MOC_COMM_WORLD);
}
MOC_Finalize(); // close MPI application
return 0;
}