Пример #1
0
int main(int argc, char** argv) {
    bsp_init("e_bsp_hp_variables.elf", argc, argv);
    bsp_begin(bsp_nprocs());
    ebsp_spmd();
    bsp_end();

    return 0;
}
Пример #2
0
int main(int argc, char **argv)
{
    bsp_init("e_bsp_memory.srec", argc, argv);
    bsp_begin(bsp_nprocs());
    ebsp_spmd();
    bsp_end();

    return 0;
}
Пример #3
0
int main(int argc, char** argv) {
    bsp_init("e_bsp_vertical_mp.srec", argc, argv);
    bsp_begin(bsp_nprocs());

    int n = bsp_nprocs();

    int tagsize = sizeof(int);
    ebsp_set_tagsize(&tagsize);

    int tag = 0;
    int payload = 0;
    for (int s = 0; s < n; ++s) {
        tag = 0;
        payload = 1000 + s;
        ebsp_send_down(s, &tag, &payload, sizeof(int));

        tag = 1;
        payload = 1234;
        ebsp_send_down(s, &tag, &payload, sizeof(int));
    }

    ebsp_spmd();

    int packets = 0;
    int accum_bytes = 0;
    ebsp_qsize(&packets, &accum_bytes);

    printf("packets: %i\n", packets);
    // FIXME nprocs
    // expect: (packets: 32)

    int* payloads = malloc(2 * n * sizeof(int));
    int payload_size = 0;
    int tag_in = 0;
    for (int i = 0; i < packets; ++i) {
        ebsp_get_tag(&payload_size, &tag_in);
        ebsp_move(&payloads[tag_in], sizeof(int));
    }

    for (int i = 0; i < n; ++i) {
        printf("$%02d: %i\n", i, payloads[i]);
        // expect_for_pid: (2000 + pid)
    }

    for (int i = n; i < 2 * n; ++i) {
        printf("$%02d: %i\n", i - bsp_nprocs(), payloads[i]);
        // expect_for_pid: (3)
    }

    free(payloads);

    bsp_end();

    return 0;
}
Пример #4
0
int main(int argc, char** argv) {
    bsp_init("e_bsp_streams.srec", argc, argv);
    bsp_begin(bsp_nprocs());

    int chunk_size = sizeof(int) * 4;
    int chunks = 4;

    int** upstreams = (int**)malloc(sizeof(int*) * bsp_nprocs());
    int** upstreamsDouble = (int**)malloc(sizeof(int*) * bsp_nprocs());
    int* downdata = (int*)malloc(chunks * chunk_size);
    int* downdataB = (int*)malloc(chunks * chunk_size);
    int* downdataDouble = (int*)malloc(chunks * chunk_size);

    int c = 0;
    for (int i = chunks * chunk_size / sizeof(int) - 1; i >= 0; --i) {
        downdata[c] = i;
        downdataB[c] = c;
        downdataDouble[c] = 2 * c;
        c++;
    }

    for (int s = 0; s < bsp_nprocs(); ++s) {
        upstreams[s] =
            (int*)ebsp_create_up_stream(s, chunks * chunk_size, chunk_size);
        upstreamsDouble[s] =
            (int*)ebsp_create_up_stream(s, chunks * chunk_size, chunk_size);
        ebsp_create_down_stream(downdata, s, chunks * chunk_size, chunk_size);
        ebsp_create_down_stream(downdataB, s, chunks * chunk_size, chunk_size);
        ebsp_create_down_stream(downdataDouble, s, chunks * chunk_size,
                                chunk_size);
    }

    ebsp_spmd();

    for (int i = 0; i < chunk_size * chunks / sizeof(int); ++i) {
        printf("%i ", upstreams[5][i]);
    }
    printf("\n");
    // expect: (0 1 2 3 11 10 9 8 8 9 10 11 3 2 1 0 )

    for (int i = 0; i < chunk_size * chunks / sizeof(int); ++i) {
        printf("%i ", upstreamsDouble[5][i]);
    }
    // expect: (30 28 26 24 22 20 18 16 14 12 10 8 6 4 2 0 )

    // finalize
    bsp_end();

    free(upstreams);
    free(downdata);
    free(downdataB);

    return 0;
}
Пример #5
0
int main(int argc, char** argv) {
    bsp_init("e_bsp_utility.srec", argc, argv);

    bsp_begin(bsp_nprocs());

    ebsp_spmd();

    bsp_end();

    printf("Done");
    // expect: (Done)
}
Пример #6
0
int main(int argc, char** argv) {
    bsp_init("e_streaming.elf", argc, argv);
    bsp_begin(bsp_nprocs());

    int chunk_size = sizeof(char) * 16;
    int chunks = 6;

    char** upstreams = (char**)malloc(sizeof(char*) * bsp_nprocs());
    char* downdata = (char*)malloc(chunks * chunk_size);
    char* downdataB = (char*)malloc(chunks * chunk_size); 

    int c = 0;
    int index1 = 0;
    int index2 = 0;
    for (int i = chunks * chunk_size / sizeof(char) - 1; i >= 0; --i) {
        downdata[c] = string1[index1++];
        downdataB[c] = string2[index2++];
        c++;

        if (index1 >= strlen(string1))
            index1 = 0;
        if (index2 >= strlen(string2))
            index2 = 0;
    }

    for (int s = 0; s < bsp_nprocs(); ++s) {
        upstreams[s] =
            (char*)ebsp_create_up_stream(s, chunks * chunk_size, chunk_size);
    }

    for (int s = 0; s < bsp_nprocs(); ++s) {
        ebsp_create_down_stream(downdata, s, chunks * chunk_size, chunk_size);
    }

    for (int s = 0; s < bsp_nprocs(); ++s) {
        ebsp_create_down_stream(downdataB, s, chunks * chunk_size, chunk_size);
    }

    ebsp_spmd();

    for (int s = 0; s < bsp_nprocs(); ++s) {
        printf("Result of processor: %i\n", s);
        for (int i = 0; i < chunk_size * chunks / sizeof(char); ++i) {
            printf("%c", upstreams[s][i]);
        }
        printf("\n\n");
    }

    // finalize
    bsp_end();

    return 0;
}
int main(int argc, char **argv)
{
	bsp_init("messages_kernel.elf", argc, argv);
	bsp_begin(16);

	int tagsize = sizeof(int);
	ebsp_set_tagsize(&tagsize);

	ebsp_spmd();

	bsp_end();

	return 0;
}
Пример #8
0
int main(int argc, char** argv) {
    // Initialize the BSP system
    if (!bsp_init("e_primitives.elf", argc, argv)) {
        fprintf(stderr, "ERROR: bsp_init() failed\n");
        return -1;
    }

    // Get the number of processors available
    int nprocs_available = bsp_nprocs();

    printf("Amount of cores available: %i\n", nprocs_available);
    for (;;) {
        printf("Enter the amount of cores to use: ");
        nprocs = 0;
        if (scanf("%d", &nprocs) < 0)
            return 1;
        if (nprocs <= 0 || nprocs > nprocs_available)
            printf("Invalid. Enter a number between 1 and %d\n",
                   nprocs_available);
        else
            break;
    }

    // Initialize the epiphany system, and load the e-program
    if (!bsp_begin(nprocs)) {
        fprintf(stderr, "ERROR: bsp_begin() failed\n");
        return -1;
    }

    // Send some initial data to the processors (i.e. matrices)
    generate_data();
    send_data();

    // Run the SPMD on the e-cores
    ebsp_spmd();

    printf("Retrieving results\n");

    // Retrieve results
    retrieve_data();

    // Finalize
    bsp_end();
}
Пример #9
0
int main(int argc, char **argv)
{
    bsp_init("e_dot_product.srec", argc, argv);
    bsp_begin(bsp_nprocs());

    // allocate two random vectors of length 512
    int l = 512;
    int* a = (int*)malloc(sizeof(int) * l);
    int* b = (int*)malloc(sizeof(int) * l);
    for (int i = 0; i < l; ++i) {
        a[i] = i;
        b[i] = 2*i;
    }

    // partition and write to processors
    int chunk = l / bsp_nprocs();
    printf("chunk: %i\n", chunk);

    int tag;
    int tagsize = sizeof(int);
    ebsp_set_tagsize(&tagsize);
    for (int pid = 0; pid < bsp_nprocs(); pid++)
    {
        tag = 1;
        ebsp_send_down(pid, &tag, &chunk, sizeof(int));
        tag = 2;
        ebsp_send_down(pid, &tag, &a[pid*chunk], sizeof(int)*chunk);
        tag = 3;
        ebsp_send_down(pid, &tag, &b[pid*chunk], sizeof(int)*chunk);
    }
    
    // enable memory inspector
    //ebsp_inspector_enable();

    // run dotproduct
    ebsp_spmd();

    // read output
    int packets, accum_bytes;
    ebsp_qsize(&packets, &accum_bytes);

    int status;
    int result;
    int sum = 0;
    printf("proc \t partial_sum\n");
    printf("---- \t -----------\n");
    for (int i = 0; i < packets; i++)
    {
        ebsp_get_tag(&status, &tag);
        ebsp_move(&result, sizeof(int));
        printf("%i: \t %i\n", tag, result);
        sum += result;
    }

    printf("SUM: %i\n", sum);

    free(a);
    free(b);

    // finalize
    bsp_end();

    return 0;
}