#include #include #include #include extern spe_program_handle_t test_jacobi_spu; int main(int argc, char **argv) { int t, rank, size, rl, mspu, aspu, err, stringl, nothr; char proc[4]; int n __attribute__((__aligned__(16))); int iterations __attribute__((__aligned__(16))); float omega __attribute__((__aligned__(16))); char string[255]; if (argc < 5) { printf("Usage: \"%s Matrix size Iterations Omega nothr\"\n", argv[0]); return -1; } n = atoi(argv[1]); iterations = atoi(argv[2]); omega = atof(argv[3]); nothr = atoi(argv[4]); 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; } // only use as many spus as specified aspu = nothr; for (t = 0; t < aspu; t++) MOC_Add_spu_thread(&test_jacobi_spu, NULL); MOC_Init(NULL, NULL); MOC_Comm_rank(MOC_COMM_WORLD, &rank); MOC_Comm_size(MOC_COMM_WORLD, &size); MOC_Get_processor_name(proc, &rl); // sending input and other runtime specific data to spes for (t = 0; t < aspu; t++) { err = MOC_Bsend(&n, sizeof(int), MOC_INT, t + 1, 123, MOC_COMM_WORLD); if (err) { MOC_Error_string(err, string, &stringl); printf("%i: ERROR-bsend1: %s (%i)\n", rank, string, err); return 0; } err = MOC_Bsend(&iterations, sizeof(int), MOC_INT, t + 1, 123, MOC_COMM_WORLD); if (err) { MOC_Error_string(err, string, &stringl); printf("%i: ERROR-bsend2: %s (%i)\n", rank, string, err); return 0; } err = MOC_Bsend(&omega, sizeof(float), MOC_FLOAT, t + 1, 123, MOC_COMM_WORLD); if (err) { MOC_Error_string(err, string, &stringl); printf("%i: ERROR-bsend3: %s (%i)\n", rank, string, err); return 0; } } MOC_Finalize(); return 0; }