Update Kokkos library in LAMMPS to v3.0

This commit is contained in:
Stan Moore
2020-03-25 14:08:39 -06:00
parent 0252d8c210
commit 60864e38d1
2169 changed files with 121406 additions and 126492 deletions

View File

@ -2,10 +2,11 @@
//@HEADER
// ************************************************************************
//
// Kokkos v. 2.0
// Copyright (2014) Sandia Corporation
// Kokkos v. 3.0
// Copyright (2020) National Technology & Engineering
// Solutions of Sandia, LLC (NTESS).
//
// Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
// Under the terms of Contract DE-NA0003525 with NTESS,
// the U.S. Government retains certain rights in this software.
//
// Redistribution and use in source and binary forms, with or without
@ -23,10 +24,10 @@
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
// THIS SOFTWARE IS PROVIDED BY NTESS "AS IS" AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL NTESS OR THE
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
@ -47,92 +48,87 @@
namespace Test {
template< class Space >
class TestUniqueToken
{
public:
typedef typename Space::execution_space execution_space;
typedef Kokkos::View< int * , execution_space > view_type ;
template <class Space>
class TestUniqueToken {
public:
typedef typename Space::execution_space execution_space;
typedef Kokkos::View<int*, execution_space> view_type;
Kokkos::Experimental::UniqueToken< execution_space , Kokkos::Experimental::UniqueTokenScope::Global > tokens ;
Kokkos::Experimental::UniqueToken<
execution_space, Kokkos::Experimental::UniqueTokenScope::Global>
tokens;
view_type verify ;
view_type counts ;
view_type errors ;
view_type verify;
view_type counts;
view_type errors;
KOKKOS_INLINE_FUNCTION
void operator()( long ) const
{
void operator()(long) const {
const int32_t t = tokens.acquire();
bool ok = true ;
bool ok = true;
ok = ok && 0 <= t ;
ok = ok && 0 <= t;
ok = ok && t < tokens.size();
ok = ok && 0 == Kokkos::atomic_fetch_add( & verify(t) , 1 );
ok = ok && 0 == Kokkos::atomic_fetch_add(&verify(t), 1);
Kokkos::atomic_fetch_add( & counts(t) , 1 );
Kokkos::atomic_fetch_add(&counts(t), 1);
ok = ok && 1 == Kokkos::atomic_fetch_add( & verify(t) , -1 );
ok = ok && 1 == Kokkos::atomic_fetch_add(&verify(t), -1);
if ( ! ok ) { Kokkos::atomic_fetch_add( & errors(0) , 1 ) ; }
if (!ok) {
Kokkos::atomic_fetch_add(&errors(0), 1);
}
tokens.release(t);
}
TestUniqueToken()
: tokens( execution_space() )
, verify( "TestUniqueTokenVerify" , tokens.size() )
, counts( "TestUniqueTokenCounts" , tokens.size() )
, errors( "TestUniqueTokenErrors" , 1 )
{}
: tokens(execution_space()),
verify("TestUniqueTokenVerify", tokens.size()),
counts("TestUniqueTokenCounts", tokens.size()),
errors("TestUniqueTokenErrors", 1) {}
static void run() {
using policy = Kokkos::RangePolicy<execution_space>;
TestUniqueToken self;
static void run()
{
using policy = Kokkos::RangePolicy<execution_space> ;
const int duplicate = 100;
const long n = duplicate * self.tokens.size();
TestUniqueToken self ;
{
const int duplicate = 100 ;
const long n = duplicate * self.tokens.size();
Kokkos::parallel_for( policy(0,n) , self );
Kokkos::parallel_for( policy(0,n) , self );
Kokkos::parallel_for( policy(0,n) , self );
Kokkos::fence();
}
typename view_type::HostMirror host_counts =
Kokkos::create_mirror_view( self.counts );
Kokkos::deep_copy( host_counts , self.counts );
int32_t max = 0 ;
{
const long n = host_counts.extent(0);
for ( long i = 0 ; i < n ; ++i ) {
if ( max < host_counts[i] ) max = host_counts[i] ;
}
}
std::cout << "TestUniqueToken max reuse = " << max << std::endl ;
typename view_type::HostMirror host_errors =
Kokkos::create_mirror_view( self.errors );
Kokkos::deep_copy( host_errors , self.errors );
ASSERT_EQ( host_errors(0) , 0 );
Kokkos::parallel_for(policy(0, n), self);
Kokkos::parallel_for(policy(0, n), self);
Kokkos::parallel_for(policy(0, n), self);
Kokkos::fence();
}
typename view_type::HostMirror host_counts =
Kokkos::create_mirror_view(self.counts);
Kokkos::deep_copy(host_counts, self.counts);
int32_t max = 0;
{
const long n = host_counts.extent(0);
for (long i = 0; i < n; ++i) {
if (max < host_counts[i]) max = host_counts[i];
}
}
std::cout << "TestUniqueToken max reuse = " << max << std::endl;
typename view_type::HostMirror host_errors =
Kokkos::create_mirror_view(self.errors);
Kokkos::deep_copy(host_errors, self.errors);
ASSERT_EQ(host_errors(0), 0);
}
};
TEST(TEST_CATEGORY, unique_token) { TestUniqueToken<TEST_EXECSPACE>::run(); }
TEST_F( TEST_CATEGORY, unique_token )
{
TestUniqueToken< TEST_EXECSPACE >::run();
}
} // namespace Test
} // namespace Test