TEST(Where, MaxDim) { const size_t largeDim = 65535 * 32 + 2; array input = range(dim4(1, largeDim), 1); array output = where(input % 2 == 0); array gold = 2 * range(largeDim / 2); ASSERT_ARRAYS_EQ(gold.as(u32), output); input = range(dim4(1, 1, 1, largeDim), 3); output = where(input % 2 == 0); ASSERT_ARRAYS_EQ(gold.as(u32), output); }
TEST(Accum, MaxDim) { const size_t largeDim = 65535 * 32 + 1; //first dimension kernel tests array input = constant(0, 2, largeDim, 2, 2); input(span, seq(0, 9999), span, span) = 1; array gold_first = constant(0, 2, largeDim, 2, 2); gold_first(span, seq(0, 9999), span, span) = range(2, 10000, 2, 2) + 1; array output_first = accum(input, 0); ASSERT_ARRAYS_EQ(gold_first, output_first); input = constant(0, 2, 2, 2, largeDim); input(span, span, span, seq(0, 9999)) = 1; gold_first = constant(0, 2, 2, 2, largeDim); gold_first(span, span, span, seq(0, 9999)) = range(2, 2, 2, 10000) + 1; output_first = accum(input, 0); ASSERT_ARRAYS_EQ(gold_first, output_first); //other dimension kernel tests input = constant(0, 2, largeDim, 2, 2); input(span, seq(0, 9999), span, span) = 1; array gold_dim = constant(10000, 2, largeDim, 2, 2); gold_dim(span, seq(0, 9999), span, span) = range(dim4(2, 10000, 2, 2), 1) + 1; array output_dim = accum(input, 1); ASSERT_ARRAYS_EQ(gold_dim, output_dim); input = constant(0, 2, 2, 2, largeDim); input(span, span, span, seq(0, 9999)) = 1; gold_dim = constant(0, 2, 2, 2, largeDim); gold_dim(span, span, span, seq(0, 9999)) = range(dim4(2, 2, 2, 10000), 1) + 1; output_dim = accum(input, 1); ASSERT_ARRAYS_EQ(gold_dim, output_dim); }
///////////////////////////////// CPP //////////////////////////////////// // TEST(Range, CPP) { if (noDoubleTests<float>()) return; const unsigned x = 23; const unsigned y = 15; const unsigned z = 4; const unsigned w = 2; const unsigned dim = 2; dim4 idims(x, y, z, w); array output = range(x, y, z, w, dim, f32); // Get result float* outData = new float[idims.elements()]; output.host((void*)outData); // Compare result for(int w = 0; w < (int)idims[3]; w++) { for(int z = 0; z < (int)idims[2]; z++) { for(int y = 0; y < (int)idims[1]; y++) { for(int x = 0; x < (int)idims[0]; x++) { float val = 0; if(dim == 0) { val = x; } else if(dim == 1) { val = y; } else if(dim == 2) { val = z; } else if(dim == 3) { val = w; } dim_t idx = (w * idims[0] * idims[1] * idims[2]) + (z * idims[0] * idims[1]) + (y * idims[0]) + x; ASSERT_EQ(val, outData[idx]) << "at: " << idx << endl; } } } } // Delete delete[] outData; }