Пример #1
0
bool test(accelerator_view &rv)
{
    const int size = 100;

    vector<int> A(size);
    vector<s> G(size);
    vector<int> Gi(size);
    vector<double> Gd(size);

    for(int i = 0; i < size; i++)
    {
        A[i] = INIT_VALUE;
    }

    extent<1> e(size);

    Concurrency::array<int, 1> aA(e, A.begin(), rv);
    Concurrency::array<s, 1> aG(e, G.begin(), rv);
    Concurrency::array<int, 1> aGi(e, Gi.begin(), rv);
    Concurrency::array<double, 1> aGd(e, Gd.begin(), rv);

    parallel_for_each(aA.get_extent(), [&](index<1>idx) __GPU
    {
        s* volatile ps = &aG[idx];
        int * volatile pi1 = &aGi[idx];
        double * volatile pd1 = &aGd[idx]; // not allowed here

        aA[idx] = 1;
    });
Пример #2
0
Файл: test.cpp Проект: 8l/kalmar
bool test(accelerator_view &rv)
{
    const int size = 100;

    vector<int> A(size);
    vector<s> G(size);
    vector<int> Gi(size);
    vector<double> Gd(size);

    for(int i = 0; i < size; i++)
    {
        A[i] = INIT_VALUE;
    }

    extent<1> e(size);

    array<int, 1> aA(e, A.begin(), rv);
    array<s, 1> aG(e, G.begin(), rv);
    array<int, 1> aGi(e, Gi.begin(), rv);
    array<double, 1> aGd(e, Gd.begin(), rv);

    parallel_for_each(aA.get_extent(), [&](index<1>idx) __GPU
    {
        const s o2 = aG[idx];

        const s* ps = &o2;

        ps->i = 1; // not allowed here
        ps->d = 1;
        ps->ul = 1;
        ps->f = 1;

        const int *pi1 = &aGi[idx];
        *pi1 = 2;
        const double d1 = 1;
        const double *pd1 = &aGd[idx];
        *pd1 = 2.0;

        aA[idx] = 1;
    });