示例#1
0
int main()
{
    bsp_begin();

    int p = bsp_pid();

    char a = 0;
    char b = 0;
    char c = 0;
    bsp_push_reg(&a, sizeof(char));
    bsp_sync();
    bsp_push_reg(&b, sizeof(char));
    bsp_sync();

    if (p == 0)
    {
        c = 'y';
        bsp_hpput(3, &c, &a, 0, sizeof(char));
        bsp_hpput(3, &c, &b, 0, sizeof(char));
    }

    bsp_end();

    return 0;
}
示例#2
0
int main() {
    bsp_begin();
    int var = bsp_pid();
    int* unregistered_var = (int*)0x7000;
    char teststr[] = "Default test string!";
    char goodstr[] = "Replacement string.";
    bsp_push_reg(&var, sizeof(int));

    if (bsp_pid() != 2)
        bsp_sync();

    bsp_push_reg(teststr, sizeof(int));

    // Only core 2 will do both registrations in the same sync
    if (bsp_pid() == 2)
        bsp_sync();
    // expect: ($02: BSP ERROR: multiple bsp_push_reg calls within one sync)

    if (bsp_pid() == 1) {
        bsp_hpput(0, &var, &var, 0, sizeof(int));
        bsp_hpput(0, &var, unregistered_var, 0, sizeof(int)); // Error
        // expect: ($01: BSP ERROR: could not find bsp var 0x7000)
    }
    if (bsp_pid() == 0) {
        bsp_hpput(1, goodstr, teststr, 0, 19 * sizeof(char));
    }

    bsp_sync();

    if (bsp_pid() == 0)
        ebsp_message("%d", var);
    // expect: ($00: 1)
    bsp_sync();
    if (bsp_pid() == 1)
        ebsp_message(teststr);
    // expect: ($01: Replacement string.!)

    bsp_end();
    return 0;
}
示例#3
0
int main() {
    bsp_begin();
    int s = bsp_pid();
    int p = bsp_nprocs();

    int a = 0;
    bsp_push_reg(&a, sizeof(int));
    bsp_sync();

    int b = 0;
    bsp_push_reg(&b, sizeof(int));
    bsp_sync();

    int c[16] = {0};
    bsp_push_reg(&c, 16 * sizeof(int));
    bsp_sync();

    // first we test puts
    int data = s;
    bsp_hpput((s + 1) % p, &data, &a, 0, sizeof(int));
    bsp_hpput((s + 2) % p, &data, &b, 0, sizeof(int));
    for (int t = 0; t < p; ++t) {
        bsp_hpput(t, &data, &c, sizeof(int) * s, sizeof(int));
    }
    ebsp_barrier();

    // test: can set and get tagsize from core
    EBSP_MSG_ORDERED("%i", a);
    // expect_for_pid: ((pid - 1) % 16)

    // test: can put register multiple vars, and put multiple times
    EBSP_MSG_ORDERED("%i", b);
    // expect_for_pid: ((pid - 2) % 16)

    // test: support for larger variables
    EBSP_MSG_ORDERED("%i", c[5]);
    // expect_for_pid: ("5")

    // next we test gets

    int core_num_next = 0;
    int core_num_next_next = 0;
    bsp_hpget((s + 1) % p, &a, 0, &core_num_next, sizeof(int));
    bsp_hpget((s + 2) % p, &b, 0, &core_num_next_next, sizeof(int));
    bsp_hpget((s + 3) % p, &c, 4 * sizeof(int), &data, sizeof(int));
    ebsp_barrier();

    // test: can set and get tagsize from core
    EBSP_MSG_ORDERED("%i", core_num_next);
    // expect_for_pid: (pid)

    // test: can put register multiple vars, and put multiple times
    EBSP_MSG_ORDERED("%i", core_num_next_next);
    // expect_for_pid: (pid)

    // test: support for larger variables
    EBSP_MSG_ORDERED("%i", data);
    // expect_for_pid: ("4")

    bsp_end();

    return 0;
}