Skip to content

Commit

Permalink
Merge pull request #887 from BenjaminW3/topic-catch2-update-part2
Browse files Browse the repository at this point in the history
Use TEMPLATE_LIST_TEST_CASE for more tests
  • Loading branch information
BenjaminW3 authored Nov 25, 2019
2 parents 1b66367 + ac27a20 commit 9136998
Show file tree
Hide file tree
Showing 7 changed files with 168 additions and 287 deletions.
32 changes: 12 additions & 20 deletions test/integ/axpy/src/axpy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,13 +73,15 @@ class AxpyKernel
}
};

struct TestTemplate
{
template< typename TAcc >
void operator()()
using TestAccs = alpaka::test::acc::EnabledAccs<
alpaka::dim::DimInt<1u>,
std::size_t>;

TEMPLATE_LIST_TEST_CASE( "axpy", "[axpy]", TestAccs)
{
using Dim = alpaka::dim::Dim<TAcc>;
using Idx = alpaka::idx::Idx<TAcc>;
using Acc = TestType;
using Dim = alpaka::dim::Dim<Acc>;
using Idx = alpaka::idx::Idx<Acc>;

#ifdef ALPAKA_CI
Idx const numElements = 1u<<9u;
Expand All @@ -88,7 +90,7 @@ void operator()()
#endif

using Val = float;
using DevAcc = alpaka::dev::Dev<TAcc>;
using DevAcc = alpaka::dev::Dev<Acc>;
using PltfAcc = alpaka::pltf::Pltf<DevAcc>;
using QueueAcc = alpaka::test::queue::DefaultQueue<DevAcc>;
using PltfHost = alpaka::pltf::PltfCpu;
Expand All @@ -112,7 +114,7 @@ void operator()()

// Let alpaka calculate good block and grid sizes given our full problem extent.
alpaka::workdiv::WorkDivMembers<Dim, Idx> const workDiv(
alpaka::workdiv::getValidWorkDiv<TAcc>(
alpaka::workdiv::getValidWorkDiv<Acc>(
devAcc,
extent,
static_cast<Idx>(3u),
Expand All @@ -122,7 +124,7 @@ void operator()()
std::cout
<< "AxpyKernel("
<< " numElements:" << numElements
<< ", accelerator: " << alpaka::acc::getAccName<TAcc>()
<< ", accelerator: " << alpaka::acc::getAccName<Acc>()
<< ", kernel: " << typeid(kernel).name()
<< ", workDiv: " << workDiv
<< ")" << std::endl;
Expand Down Expand Up @@ -181,7 +183,7 @@ void operator()()
#endif

// Create the kernel execution task.
auto const taskKernel(alpaka::kernel::createTaskKernel<TAcc>(
auto const taskKernel(alpaka::kernel::createTaskKernel<Acc>(
workDiv,
kernel,
numElements,
Expand Down Expand Up @@ -218,13 +220,3 @@ void operator()()

REQUIRE(resultCorrect);
}
};

TEST_CASE( "axpy", "[axpy]")
{
using TestAccs = alpaka::test::acc::EnabledAccs<
alpaka::dim::DimInt<1u>,
std::size_t>;

alpaka::meta::forEachType< TestAccs >( TestTemplate() );
}
34 changes: 13 additions & 21 deletions test/integ/mandelbrot/src/mandelbrot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -302,13 +302,15 @@ auto writeTgaColorImage(
}
}

struct TestTemplate
{
template< typename TAcc >
void operator()()
using TestAccs = alpaka::test::acc::EnabledAccs<
alpaka::dim::DimInt<2u>,
std::uint32_t>;

TEMPLATE_LIST_TEST_CASE( "mandelbrot", "[mandelbrot]", TestAccs)
{
using Dim = alpaka::dim::Dim<TAcc>;
using Idx = alpaka::idx::Idx<TAcc>;
using Acc = TestType;
using Dim = alpaka::dim::Dim<Acc>;
using Idx = alpaka::idx::Idx<Acc>;

#ifdef ALPAKA_CI
Idx const imageSize(1u<<5u);
Expand All @@ -324,7 +326,7 @@ void operator()()
Idx const maxIterations(300u);

using Val = std::uint32_t;
using DevAcc = alpaka::dev::Dev<TAcc>;
using DevAcc = alpaka::dev::Dev<Acc>;
using PltfAcc = alpaka::pltf::Pltf<DevAcc>;
using QueueAcc = alpaka::test::queue::DefaultQueue<DevAcc>;
using PltfHost = alpaka::pltf::PltfCpu;
Expand All @@ -350,7 +352,7 @@ void operator()()

// Let alpaka calculate good block and grid sizes given our full problem extent.
alpaka::workdiv::WorkDivMembers<Dim, Idx> const workDiv(
alpaka::workdiv::getValidWorkDiv<TAcc>(
alpaka::workdiv::getValidWorkDiv<Acc>(
devAcc,
extent,
alpaka::vec::Vec<Dim, Idx>::ones(),
Expand All @@ -362,7 +364,7 @@ void operator()()
<< " numRows:" << numRows
<< ", numCols:" << numCols
<< ", maxIterations:" << maxIterations
<< ", accelerator: " << alpaka::acc::getAccName<TAcc>()
<< ", accelerator: " << alpaka::acc::getAccName<Acc>()
<< ", kernel: " << typeid(kernel).name()
<< ", workDiv: " << workDiv
<< ")" << std::endl;
Expand All @@ -379,7 +381,7 @@ void operator()()
alpaka::mem::view::copy(queue, bufColorAcc, bufColorHost, extent);

// Create the kernel execution task.
auto const taskKernel(alpaka::kernel::createTaskKernel<TAcc>(
auto const taskKernel(alpaka::kernel::createTaskKernel<Acc>(
workDiv,
kernel,
alpaka::mem::view::getPtrNative(bufColorAcc),
Expand Down Expand Up @@ -407,20 +409,10 @@ void operator()()
alpaka::wait::wait(queue);

// Write the image to a file.
std::string fileName("mandelbrot"+std::to_string(numCols)+"x"+std::to_string(numRows)+"_"+alpaka::acc::getAccName<TAcc>()+".tga");
std::string fileName("mandelbrot"+std::to_string(numCols)+"x"+std::to_string(numRows)+"_"+alpaka::acc::getAccName<Acc>()+".tga");
std::replace(fileName.begin(), fileName.end(), '<', '_');
std::replace(fileName.begin(), fileName.end(), '>', '_');
writeTgaColorImage(
fileName,
bufColorHost);
}
};

TEST_CASE( "mandelbrot", "[mandelbrot]")
{
using TestAccs = alpaka::test::acc::EnabledAccs<
alpaka::dim::DimInt<2u>,
std::uint32_t>;

alpaka::meta::forEachType< TestAccs >( TestTemplate() );
}
34 changes: 13 additions & 21 deletions test/integ/matMul/src/matMul.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -199,23 +199,25 @@ namespace alpaka
}
}

struct TestTemplate
{
template< typename TAcc >
void operator()()
using TestAccs = alpaka::test::acc::EnabledAccs<
alpaka::dim::DimInt<2u>,
std::uint32_t>;

TEMPLATE_LIST_TEST_CASE( "matMul", "[matMul]", TestAccs)
{
using Dim = alpaka::dim::Dim<TAcc>;
using Idx = alpaka::idx::Idx<TAcc>;
using Acc = TestType;
using Dim = alpaka::dim::Dim<Acc>;
using Idx = alpaka::idx::Idx<Acc>;

Idx const m(64u);
Idx const n(79u);
Idx const k(23u);

using Val = std::uint32_t;
using Vec2 = alpaka::vec::Vec<Dim, Idx>;
using DevAcc = alpaka::dev::Dev<TAcc>;
using DevAcc = alpaka::dev::Dev<Acc>;
using PltfAcc = alpaka::pltf::Pltf<DevAcc>;
using QueueAcc = alpaka::test::queue::DefaultQueue<alpaka::dev::Dev<TAcc>>;
using QueueAcc = alpaka::test::queue::DefaultQueue<alpaka::dev::Dev<Acc>>;
using PltfHost = alpaka::pltf::PltfCpu;
using DevHost = alpaka::dev::Dev<PltfHost>;
using QueueHost = alpaka::queue::QueueCpuNonBlocking;
Expand Down Expand Up @@ -255,7 +257,7 @@ void operator()()

// Let alpaka calculate good block and grid sizes given our full problem extent.
alpaka::workdiv::WorkDivMembers<Dim, Idx> const workDiv(
alpaka::workdiv::getValidWorkDiv<TAcc>(
alpaka::workdiv::getValidWorkDiv<Acc>(
devAcc,
extentC,
alpaka::vec::Vec<Dim, Idx>::ones(),
Expand All @@ -267,7 +269,7 @@ void operator()()
<< "m:" << m
<< ", n:" << n
<< ", k:" << k
<< ", accelerator: " << alpaka::acc::getAccName<TAcc>()
<< ", accelerator: " << alpaka::acc::getAccName<Acc>()
<< ", kernel: " << typeid(kernel).name()
<< ", workDiv: " << workDiv
<< ")" << std::endl;
Expand Down Expand Up @@ -304,7 +306,7 @@ void operator()()
alpaka::mem::view::copy(queueAcc, bufCAcc, bufCHost, extentC);

// Create the kernel execution task.
auto const taskKernel(alpaka::kernel::createTaskKernel<TAcc>(
auto const taskKernel(alpaka::kernel::createTaskKernel<Acc>(
workDiv,
kernel,
m,
Expand Down Expand Up @@ -353,13 +355,3 @@ void operator()()

REQUIRE(resultCorrect);
}
};

TEST_CASE( "matMul", "[matMul]")
{
using TestAccs = alpaka::test::acc::EnabledAccs<
alpaka::dim::DimInt<2u>,
std::uint32_t>;

alpaka::meta::forEachType< TestAccs >( TestTemplate() );
}
32 changes: 12 additions & 20 deletions test/integ/separableCompilation/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,18 +69,20 @@ class SqrtKernel
}
};

struct TestTemplate
{
template< typename TAcc >
void operator()()
using TestAccs = alpaka::test::acc::EnabledAccs<
alpaka::dim::DimInt<1u>,
std::size_t>;

TEMPLATE_LIST_TEST_CASE( "separableCompilation", "[separableCompilation]", TestAccs)
{
using Idx = alpaka::idx::Idx<TAcc>;
using Acc = TestType;
using Idx = alpaka::idx::Idx<Acc>;

using Val = double;

using DevAcc = alpaka::dev::Dev<TAcc>;
using DevAcc = alpaka::dev::Dev<Acc>;
using PltfAcc = alpaka::pltf::Pltf<DevAcc>;
using QueueAcc = alpaka::test::queue::DefaultQueue<alpaka::dev::Dev<TAcc>>;
using QueueAcc = alpaka::test::queue::DefaultQueue<alpaka::dev::Dev<Acc>>;
using PltfHost = alpaka::pltf::PltfCpu;
using DevHost = alpaka::dev::Dev<PltfHost>;

Expand All @@ -106,7 +108,7 @@ void operator()()

// Let alpaka calculate good block and grid sizes given our full problem extent.
alpaka::workdiv::WorkDivMembers<alpaka::dim::DimInt<1u>, Idx> const workDiv(
alpaka::workdiv::getValidWorkDiv<TAcc>(
alpaka::workdiv::getValidWorkDiv<Acc>(
devAcc,
extent,
static_cast<Idx>(3u),
Expand All @@ -115,7 +117,7 @@ void operator()()

std::cout
<< typeid(kernel).name() << "("
<< "accelerator: " << alpaka::acc::getAccName<TAcc>()
<< "accelerator: " << alpaka::acc::getAccName<Acc>()
<< ", workDiv: " << workDiv
<< ", numElements:" << numElements
<< ")" << std::endl;
Expand All @@ -142,7 +144,7 @@ void operator()()
alpaka::mem::view::copy(queueAcc, memBufAccB, memBufHostB, extent);

// Create the executor task.
auto const taskKernel(alpaka::kernel::createTaskKernel<TAcc>(
auto const taskKernel(alpaka::kernel::createTaskKernel<Acc>(
workDiv,
kernel,
alpaka::mem::view::getPtrNative(memBufAccA),
Expand Down Expand Up @@ -180,13 +182,3 @@ void operator()()

REQUIRE(true == resultCorrect);
}
};

TEST_CASE( "separableCompilation", "[separableCompilation]")
{
using TestAccs = alpaka::test::acc::EnabledAccs<
alpaka::dim::DimInt<1u>,
std::size_t>;

alpaka::meta::forEachType< TestAccs >( TestTemplate() );
}
32 changes: 12 additions & 20 deletions test/integ/sharedMem/src/sharedMem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -134,20 +134,22 @@ namespace alpaka
}
}

struct TestTemplate
{
template< typename TAcc >
void operator()()
using TestAccs = alpaka::test::acc::EnabledAccs<
alpaka::dim::DimInt<1u>,
std::uint32_t>;

TEMPLATE_LIST_TEST_CASE( "sharedMem", "[sharedMem]", TestAccs)
{
using Dim = alpaka::dim::Dim<TAcc>;
using Idx = alpaka::idx::Idx<TAcc>;
using Acc = TestType;
using Dim = alpaka::dim::Dim<Acc>;
using Idx = alpaka::idx::Idx<Acc>;

Idx const numElements = 1u<<16u;

using Val = std::int32_t;
using TnumUselessWork = std::integral_constant<Idx, 100>;

using DevAcc = alpaka::dev::Dev<TAcc>;
using DevAcc = alpaka::dev::Dev<Acc>;
using PltfAcc = alpaka::pltf::Pltf<DevAcc>;
using QueueAcc = alpaka::test::queue::DefaultQueue<DevAcc>;

Expand All @@ -165,7 +167,7 @@ void operator()()

// Set the grid blocks extent.
alpaka::workdiv::WorkDivMembers<Dim, Idx> const workDiv(
alpaka::workdiv::getValidWorkDiv<TAcc>(
alpaka::workdiv::getValidWorkDiv<Acc>(
devAcc,
numElements,
static_cast<Idx>(1u),
Expand All @@ -174,7 +176,7 @@ void operator()()

std::cout
<< "SharedMemKernel("
<< " accelerator: " << alpaka::acc::getAccName<TAcc>()
<< " accelerator: " << alpaka::acc::getAccName<Acc>()
<< ", kernel: " << typeid(kernel).name()
<< ", workDiv: " << workDiv
<< ")" << std::endl;
Expand All @@ -193,7 +195,7 @@ void operator()()
alpaka::mem::view::copy(queue, blockRetValsAcc, blockRetVals, resultElemCount);

// Create the kernel execution task.
auto const taskKernel(alpaka::kernel::createTaskKernel<TAcc>(
auto const taskKernel(alpaka::kernel::createTaskKernel<Acc>(
workDiv,
kernel,
alpaka::mem::view::getPtrNative(blockRetValsAcc)));
Expand Down Expand Up @@ -229,13 +231,3 @@ void operator()()

REQUIRE(resultCorrect);
}
};

TEST_CASE( "sharedMem", "[sharedMem]")
{
using TestAccs = alpaka::test::acc::EnabledAccs<
alpaka::dim::DimInt<1u>,
std::uint32_t>;

alpaka::meta::forEachType< TestAccs >( TestTemplate() );
}
Loading

0 comments on commit 9136998

Please sign in to comment.