Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a test for the dependency on host-only types from alpaka libraries #45285

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions HeterogeneousCore/AlpakaTest/BuildFile.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
<use name="FWCore/Framework"/>
<use name="HeterogeneousCore/AlpakaCore"/>
<use name="HeterogeneousCore/AlpakaInterface"/>
<!--
Let the alpaka libraries depend on the main library.
The possible syntaxes are:
<use name="HeterogeneousCore/AlpakaTest" for="alpaka"/>
<use name="1" for="alpaka"/>
<flags USE_ALPAKA="1"/>
-->
<use name="HeterogeneousCore/AlpakaTest" for="alpaka"/>
<flags ALPAKA_BACKENDS="1"/>
<export>
<lib name="1"/>
Expand Down
21 changes: 21 additions & 0 deletions HeterogeneousCore/AlpakaTest/interface/HostOnlyType.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#ifndef HeterogeneousCore_AlpakaTest_interface_HostOnlyType_h
#define HeterogeneousCore_AlpakaTest_interface_HostOnlyType_h

namespace alpakatest {

/* A simple class to demonstarte the dependency on host-only types from alpaka libraries */
class HostOnlyType {
public:
HostOnlyType() : value_{0} {}
HostOnlyType(int value) : value_{value} {}
void set(int value) { value_ = value; }
int get() { return value_; }
void print();

private:
int value_;
};

} // namespace alpakatest

#endif // HeterogeneousCore_AlpakaTest_interface_HostOnlyType_h
12 changes: 12 additions & 0 deletions HeterogeneousCore/AlpakaTest/interface/alpaka/printAnswer.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#ifndef HeterogeneousCore_AlpakaTest_interface_alpaka_printAnswer_h
#define HeterogeneousCore_AlpakaTest_interface_alpaka_printAnswer_h

#include "HeterogeneousCore/AlpakaInterface/interface/config.h"

namespace ALPAKA_ACCELERATOR_NAMESPACE::alpakatest {

void printAnswer();

} // namespace ALPAKA_ACCELERATOR_NAMESPACE::alpakatest

#endif // HeterogeneousCore_AlpakaTest_interface_alpaka_printAnswer_h
9 changes: 9 additions & 0 deletions HeterogeneousCore/AlpakaTest/src/HostOnlyType.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#include <iostream>

#include "HeterogeneousCore/AlpakaTest/interface/HostOnlyType.h"

namespace alpakatest {

void HostOnlyType::print() { std::cout << "The HostOnlyType value is " << value_ << '\n'; }

} // namespace alpakatest
14 changes: 14 additions & 0 deletions HeterogeneousCore/AlpakaTest/src/alpaka/printAnswer.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#include "HeterogeneousCore/AlpakaInterface/interface/config.h"
#include "HeterogeneousCore/AlpakaTest/interface/HostOnlyType.h"
#include "HeterogeneousCore/AlpakaTest/interface/alpaka/printAnswer.h"

namespace ALPAKA_ACCELERATOR_NAMESPACE::alpakatest {
using namespace ::alpakatest;

// A simple function to demonstarte the dependency on host-only types from alpaka libraries
void printAnswer() {
HostOnlyType answer(42);
answer.print();
}

} // namespace ALPAKA_ACCELERATOR_NAMESPACE::alpakatest
6 changes: 6 additions & 0 deletions HeterogeneousCore/AlpakaTest/test/BuildFile.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,9 @@
<!-- dependence only to trigger the unit test when AMD GPU is (expected to be) present -->
<use name="rocm"/>
</test>

<bin name="alpakaTestPrintAnswer" file="alpaka/printAnswer.cpp">
<use name="HeterogeneousCore/AlpakaInterface"/>
<use name='HeterogeneousCore/AlpakaTest'/>
<flags ALPAKA_BACKENDS="1"/>
</bin>
8 changes: 8 additions & 0 deletions HeterogeneousCore/AlpakaTest/test/alpaka/printAnswer.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#include "HeterogeneousCore/AlpakaInterface/interface/config.h"
#include "HeterogeneousCore/AlpakaTest/interface/alpaka/printAnswer.h"

// each test binary is built for a single Alpaka backend
using namespace ALPAKA_ACCELERATOR_NAMESPACE;
using namespace ALPAKA_ACCELERATOR_NAMESPACE::alpakatest;

int main() { printAnswer(); }