Skip to content

Commit

Permalink
fix error with queue in fixture
Browse files Browse the repository at this point in the history
  • Loading branch information
AuroraPerego committed Feb 22, 2024
1 parent 04bda91 commit 68df8f2
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 39 deletions.
36 changes: 27 additions & 9 deletions include/alpaka/test/KernelExecutionFixture.hpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Copyright 2023 Benjamin Worpitz, Andrea Bocci, Bernhard Manfred Gruber, Jan Stephan
/* Copyright 2023 Benjamin Worpitz, Andrea Bocci, Bernhard Manfred Gruber, Jan Stephan, Aurora Perego
* SPDX-License-Identifier: MPL-2.0
*/

Expand Down Expand Up @@ -34,18 +34,35 @@ namespace alpaka::test
using Queue = test::DefaultQueue<Device>;
using WorkDiv = WorkDivMembers<Dim, Idx>;

KernelExecutionFixture(WorkDiv workDiv) : m_workDiv{std::move(workDiv)}
KernelExecutionFixture(WorkDiv workDiv) : m_queue{m_device}, m_workDiv{std::move(workDiv)}
{
}

template<typename TExtent>
KernelExecutionFixture(TExtent const& extent)
: m_workDiv{getValidWorkDiv<Acc>(
m_device,
extent,
Vec<Dim, Idx>::ones(),
false,
GridBlockExtentSubDivRestrictions::Unrestricted)}
: m_queue{m_device}
, m_workDiv{getValidWorkDiv<Acc>(
m_device,
extent,
Vec<Dim, Idx>::ones(),
false,
GridBlockExtentSubDivRestrictions::Unrestricted)}
{
}

KernelExecutionFixture(Queue& queue, WorkDiv workDiv) : m_queue{queue}, m_workDiv{std::move(workDiv)}
{
}

template<typename TExtent>
KernelExecutionFixture(Queue& queue, TExtent const& extent)
: m_queue{queue}
, m_workDiv{getValidWorkDiv<Acc>(
m_device,
extent,
Vec<Dim, Idx>::ones(),
false,
GridBlockExtentSubDivRestrictions::Unrestricted)}
{
}

Expand Down Expand Up @@ -73,7 +90,8 @@ namespace alpaka::test
DevCpu m_devHost{getDevByIdx(m_platformHost, 0)};
Platform m_platform{};
Device m_device{getDevByIdx(m_platform, 0)};
Queue m_queue{m_device};
Queue m_queue;
WorkDiv m_workDiv;
};

} // namespace alpaka::test
40 changes: 10 additions & 30 deletions test/unit/mem/view/src/ViewStaticAccMem.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* Copyright 2023 Axel Huebl, Benjamin Worpitz, Matthias Werner, Bernhard Manfred Gruber, Jan Stephan, Andrea Bocci
* SPDX-License-Identifier: MPL-2.0
/* Copyright 2023 Axel Huebl, Benjamin Worpitz, Matthias Werner, Bernhard Manfred Gruber, Jan Stephan, Andrea Bocci,
* Aurora Perego SPDX-License-Identifier: MPL-2.0
*/

#include <alpaka/core/BoostPredef.hpp>
Expand All @@ -16,19 +16,8 @@ using Elem = std::uint32_t;
using Dim = alpaka::DimInt<2u>;
using Idx = std::uint32_t;

// These forward declarations are only necessary when you want to access those variables
// from a different compilation unit and should be moved to a common header.
// Here they are used to silence clang`s -Wmissing-variable-declarations warning
// that forces every non-static variable to be declared with extern before the are defined.
// EXTERN_ALPAKA_STATIC_ACC_MEM_GLOBAL(Elem[3][2], g_globalMemory2DUninitialized);
//EXTERN_ALPAKA_STATIC_ACC_MEM_GLOBAL(Elem[3][2], g_globalMemory2DUninitialized);
ALPAKA_STATIC_ACC_MEM_GLOBAL(Elem[3][2], g_globalMemory2DUninitialized);

// These forward declarations are only necessary when you want to access those variables
// from a different compilation unit and should be moved to a common header.
// Here they are used to silence clang`s -Wmissing-variable-declarations warning
// that forces every non-static variable to be declared with extern before the are defined.
// EXTERN_ALPAKA_STATIC_ACC_MEM_CONSTANT(Elem[3][2], g_constantMemory2DUninitialized);
ALPAKA_STATIC_ACC_MEM_CONSTANT(Elem[3][2], g_constantMemory2DUninitialized);

//! Uses static device memory on the accelerator defined globally for the whole compilation unit.
Expand All @@ -46,10 +35,6 @@ struct StaticDeviceMemoryTestKernel
auto const val = offset;

ALPAKA_CHECK(*success, val == *((&g_globalMemory2DUninitialized<TAcc>.get())[0][0] + offset));
printf(
"%u = %u\n",
val,
*((&g_globalMemory2DUninitialized<TAcc>.get())[0][0] + offset)); // compila anche senza get()
}
};

Expand All @@ -66,10 +51,6 @@ struct ConstantDeviceMemoryTestKernel
auto const val = offset;

ALPAKA_CHECK(*success, val == *((&g_constantMemory2DUninitialized<TAcc>.get())[0][0] + offset));
printf(
"%u = %u\n",
val,
*((&g_constantMemory2DUninitialized<TAcc>.get())[0][0] + offset)); // compila anche senza get()
}
};

Expand All @@ -96,15 +77,10 @@ TEMPLATE_LIST_TEST_CASE("staticDeviceMemoryGlobal", "[viewStaticAccMem]", TestAc

auto const platformAcc = alpaka::Platform<Acc>{};

std::cout << " acc:" << alpaka::core::demangled<Acc> << std::endl;
auto const devAcc = alpaka::getDevByIdx(platformAcc, 0);

alpaka::Vec<Dim, Idx> const extent(3u, 2u);

alpaka::test::KernelExecutionFixture<Acc> fixture(extent);

StaticDeviceMemoryTestKernel kernel;

// uninitialized static global device memory
{
auto const platformHost = alpaka::PlatformCpu{};
Expand All @@ -113,6 +89,10 @@ TEMPLATE_LIST_TEST_CASE("staticDeviceMemoryGlobal", "[viewStaticAccMem]", TestAc
using QueueAcc = alpaka::test::DefaultQueue<DevAcc>;
QueueAcc queueAcc(devAcc);

alpaka::test::KernelExecutionFixture<Acc> fixture(queueAcc, extent);

StaticDeviceMemoryTestKernel kernel;

std::vector<Elem> const data{0u, 1u, 2u, 3u, 4u, 5u};
auto bufHost = alpaka::createView(devHost, data.data(), extent);

Expand All @@ -139,10 +119,6 @@ TEMPLATE_LIST_TEST_CASE("staticDeviceMemoryConstant", "[viewStaticAccMem]", Test

alpaka::Vec<Dim, Idx> const extent(3u, 2u);

alpaka::test::KernelExecutionFixture<Acc> fixture(extent);

ConstantDeviceMemoryTestKernel kernel;

// uninitialized static constant device memory
{
auto const platformHost = alpaka::PlatformCpu{};
Expand All @@ -151,6 +127,10 @@ TEMPLATE_LIST_TEST_CASE("staticDeviceMemoryConstant", "[viewStaticAccMem]", Test
using QueueAcc = alpaka::test::DefaultQueue<DevAcc>;
QueueAcc queueAcc(devAcc);

alpaka::test::KernelExecutionFixture<Acc> fixture(queueAcc, extent);

ConstantDeviceMemoryTestKernel kernel;

std::vector<Elem> const data{0u, 1u, 2u, 3u, 4u, 5u};
auto bufHost = alpaka::createView(devHost, data.data(), extent);

Expand Down

0 comments on commit 68df8f2

Please sign in to comment.