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

Remove volatile qualifiers in reducer join(), init(), and operator+= methods #1382

Merged
merged 3 commits into from
Jul 18, 2022
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
119 changes: 59 additions & 60 deletions example/fenl/TestFixture.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,102 +56,101 @@
namespace Kokkos {
namespace Example {

template< class Device >
struct FixtureVerifyElemNodeCoord
{
typedef Device execution_space ;
template <class Device>
struct FixtureVerifyElemNodeCoord {
typedef Device execution_space;

typedef struct { size_t success , error ; } value_type ;
typedef struct {
size_t success, error;
} value_type;

typedef Kokkos::Example::BoxElemFixture< Device , Kokkos::Example::BoxElemPart::ElemLinear > FixtureType ;
typedef Kokkos::Example::BoxElemFixture<
Device, Kokkos::Example::BoxElemPart::ElemLinear>
FixtureType;

FixtureType m_fixture ;
FixtureType m_fixture;

KOKKOS_INLINE_FUNCTION
void init( value_type & update ) const { update.success = update.error = 0 ; }
void init(value_type& update) const { update.success = update.error = 0; }

KOKKOS_INLINE_FUNCTION
void join( volatile value_type & update ,
volatile const value_type & input ) const
{
update.success += input.success ;
update.error += input.error ;
}

void join(value_type& update, const value_type& input) const {
update.success += input.success;
update.error += input.error;
}

KOKKOS_INLINE_FUNCTION
void operator()( size_t ielem , value_type & update ) const
{
unsigned node_coord[ FixtureType::ElemNode ][3] ;

for ( unsigned i = 0 ; i < FixtureType::ElemNode ; ++i ) {
const unsigned node_id = m_fixture.elem_node(ielem,i);
node_coord[i][0] = m_fixture.node_grid(node_id,0);
node_coord[i][1] = m_fixture.node_grid(node_id,1);
node_coord[i][2] = m_fixture.node_grid(node_id,2);
void operator()(size_t ielem, value_type& update) const {
unsigned node_coord[FixtureType::ElemNode][3];

for (unsigned i = 0; i < FixtureType::ElemNode; ++i) {
const unsigned node_id = m_fixture.elem_node(ielem, i);
node_coord[i][0] = m_fixture.node_grid(node_id, 0);
node_coord[i][1] = m_fixture.node_grid(node_id, 1);
node_coord[i][2] = m_fixture.node_grid(node_id, 2);
}

int error = 0 ;
for ( unsigned i = 1 ; i < FixtureType::ElemNode ; ++i ) {
if ( node_coord[0][0] + m_fixture.elem_node_local(i,0) != node_coord[i][0] ||
node_coord[0][1] + m_fixture.elem_node_local(i,1) != node_coord[i][1] ||
node_coord[0][2] + m_fixture.elem_node_local(i,2) != node_coord[i][2] ) {
error = 1 ;
int error = 0;
for (unsigned i = 1; i < FixtureType::ElemNode; ++i) {
if (node_coord[0][0] + m_fixture.elem_node_local(i, 0) !=
node_coord[i][0] ||
node_coord[0][1] + m_fixture.elem_node_local(i, 1) !=
node_coord[i][1] ||
node_coord[0][2] + m_fixture.elem_node_local(i, 2) !=
node_coord[i][2]) {
error = 1;
}
}

if ( error ) {
++update.error ;
}
else {
++update.success ;
if (error) {
++update.error;
} else {
++update.success;
}
}

FixtureVerifyElemNodeCoord( const FixtureType & f ) : m_fixture(f) {}
FixtureVerifyElemNodeCoord(const FixtureType& f) : m_fixture(f) {}
};

template <class Device>
void test_fixture() {
typedef Kokkos::Example::BoxElemFixture<
Device, Kokkos::Example::BoxElemPart::ElemLinear>
FixtureType;

template< class Device >
void test_fixture()
{
typedef Kokkos::Example::BoxElemFixture< Device , Kokkos::Example::BoxElemPart::ElemLinear > FixtureType ;

const Kokkos::Example::BoxElemPart::Decompose
decompose = Kokkos::Example::BoxElemPart:: DecomposeElem ; // DecomposeElem | DecomposeNode ;

const unsigned global_size = 256 ;
const unsigned global_nx = 400 ;
const unsigned global_ny = 400 ;
const unsigned global_nz = 400 ;
const Kokkos::Example::BoxElemPart::Decompose decompose =
Kokkos::Example::BoxElemPart::DecomposeElem; // DecomposeElem |
// DecomposeNode ;

for ( unsigned my_rank = 0 ; my_rank < global_size ; ++my_rank ) {
const unsigned global_size = 256;
const unsigned global_nx = 400;
const unsigned global_ny = 400;
const unsigned global_nz = 400;

const FixtureType fixture( decompose , global_size , my_rank , global_nx , global_ny , global_nz );
for (unsigned my_rank = 0; my_rank < global_size; ++my_rank) {
const FixtureType fixture(decompose, global_size, my_rank, global_nx,
global_ny, global_nz);

// Verify grid coordinates of element's nodes

typename FixtureVerifyElemNodeCoord<Device>::value_type result = { 0 , 0 };

Kokkos::parallel_reduce( fixture.elem_node().extent(0) , FixtureVerifyElemNodeCoord<Device>( fixture ) , result );
typename FixtureVerifyElemNodeCoord<Device>::value_type result = {0, 0};

if ( result.error ) {
Kokkos::parallel_reduce(fixture.elem_node().extent(0),
FixtureVerifyElemNodeCoord<Device>(fixture),
result);

if (result.error) {
std::cout << "P[" << my_rank << ":" << global_size
<< "] Fixture elem_node_coord"
<< " success(" << result.success << ")"
<< " error(" << result.error << ")"
<< std::endl ;
<< " error(" << result.error << ")" << std::endl;
}

// Check send/recv alignment


}
}


} /* namespace Example */
} /* namespace Kokkos */

#endif /* #ifndef KOKKOS_EXAMPLE_TESTFIXTURE_HPP */

Loading