Update Kokkos library in LAMMPS to v3.5.0
This commit is contained in:
@ -47,7 +47,7 @@
|
||||
#include <iostream>
|
||||
#include <cstdlib>
|
||||
#include <cstdio>
|
||||
#include <impl/Kokkos_Timer.hpp>
|
||||
#include <Kokkos_Timer.hpp>
|
||||
#include <Kokkos_Core.hpp>
|
||||
#include <Kokkos_Random.hpp>
|
||||
#include <cmath>
|
||||
@ -198,11 +198,50 @@ struct test_random_functor {
|
||||
static_cast<uint64_t>(1.0 * HIST_DIM3D * tmp2 / theMax);
|
||||
const uint64_t ind3_3d =
|
||||
static_cast<uint64_t>(1.0 * HIST_DIM3D * tmp3 / theMax);
|
||||
|
||||
// Workaround Intel 17 compiler bug which sometimes add random
|
||||
// instruction alignment which makes the lock instruction
|
||||
// illegal. Seems to be mostly just for unsigned int atomics.
|
||||
// Looking at the assembly the compiler
|
||||
// appears to insert cache line alignment for the instruction.
|
||||
// Isn't restricted to specific archs. Seen it on SNB and SKX, but for
|
||||
// different code. Another occurrence was with Desul atomics in
|
||||
// a different unit test. This one here happens without desul atomics.
|
||||
// Inserting an assembly nop instruction changes the alignment and
|
||||
// works round this.
|
||||
//
|
||||
// 17.0.4 for 64bit Random works with 1/1/1/2/1
|
||||
// 17.0.4 for 1024bit Random works with 1/1/1/1/1
|
||||
#ifdef KOKKOS_COMPILER_INTEL
|
||||
#if (KOKKOS_COMPILER_INTEL < 1800)
|
||||
asm volatile("nop\n");
|
||||
#endif
|
||||
#endif
|
||||
atomic_fetch_add(&density_1d(ind1_1d), 1);
|
||||
#ifdef KOKKOS_COMPILER_INTEL
|
||||
#if (KOKKOS_COMPILER_INTEL < 1800)
|
||||
asm volatile("nop\n");
|
||||
#endif
|
||||
#endif
|
||||
atomic_fetch_add(&density_1d(ind2_1d), 1);
|
||||
#ifdef KOKKOS_COMPILER_INTEL
|
||||
#if (KOKKOS_COMPILER_INTEL < 1800)
|
||||
asm volatile("nop\n");
|
||||
#endif
|
||||
#endif
|
||||
atomic_fetch_add(&density_1d(ind3_1d), 1);
|
||||
#ifdef KOKKOS_COMPILER_INTEL
|
||||
#if (KOKKOS_COMPILER_INTEL < 1800)
|
||||
if (std::is_same<rnd_type, Kokkos::Random_XorShift64<device_type>>::value)
|
||||
asm volatile("nop\n");
|
||||
asm volatile("nop\n");
|
||||
#endif
|
||||
#endif
|
||||
atomic_fetch_add(&density_3d(ind1_3d, ind2_3d, ind3_3d), 1);
|
||||
#ifdef KOKKOS_COMPILER_INTEL
|
||||
#if (KOKKOS_COMPILER_INTEL < 1800)
|
||||
asm volatile("nop\n");
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
rand_pool.free_state(rand_gen);
|
||||
}
|
||||
@ -338,9 +377,11 @@ struct test_random_scalar {
|
||||
using functor_type =
|
||||
test_histogram1d_functor<typename RandomGenerator::device_type>;
|
||||
parallel_reduce(HIST_DIM1D, functor_type(density_1d, num_draws), result);
|
||||
|
||||
double tolerance = 6 * std::sqrt(1.0 / HIST_DIM1D);
|
||||
double mean_expect = 1.0 * num_draws * 3 / HIST_DIM1D;
|
||||
double mean_eps_expect = 0.0001;
|
||||
double variance_eps_expect = 0.07;
|
||||
double covariance_eps_expect = 0.06;
|
||||
double tolerance = 6 * std::sqrt(1.0 / HIST_DIM1D);
|
||||
double mean_expect = 1.0 * num_draws * 3 / HIST_DIM1D;
|
||||
double variance_expect =
|
||||
1.0 * num_draws * 3 / HIST_DIM1D * (1.0 - 1.0 / HIST_DIM1D);
|
||||
double covariance_expect = -1.0 * num_draws * 3 / HIST_DIM1D / HIST_DIM1D;
|
||||
@ -349,11 +390,26 @@ struct test_random_scalar {
|
||||
variance_expect / (result.variance / HIST_DIM1D) - 1.0;
|
||||
double covariance_eps =
|
||||
(result.covariance / HIST_DIM1D - covariance_expect) / mean_expect;
|
||||
pass_hist1d_mean = ((-0.0001 < mean_eps) && (0.0001 > mean_eps)) ? 1 : 0;
|
||||
pass_hist1d_var =
|
||||
((-0.07 < variance_eps) && (0.07 > variance_eps)) ? 1 : 0;
|
||||
pass_hist1d_covar =
|
||||
((-0.06 < covariance_eps) && (0.06 > covariance_eps)) ? 1 : 0;
|
||||
|
||||
#if defined(KOKKOS_HALF_T_IS_FLOAT) && !KOKKOS_HALF_T_IS_FLOAT
|
||||
if (std::is_same<Scalar, Kokkos::Experimental::half_t>::value) {
|
||||
mean_eps_expect = 0.0003;
|
||||
variance_eps_expect = 1.0;
|
||||
covariance_eps_expect = 5.0e4;
|
||||
}
|
||||
#endif
|
||||
|
||||
pass_hist1d_mean =
|
||||
((-mean_eps_expect < mean_eps) && (mean_eps_expect > mean_eps)) ? 1
|
||||
: 0;
|
||||
pass_hist1d_var = ((-variance_eps_expect < variance_eps) &&
|
||||
(variance_eps_expect > variance_eps))
|
||||
? 1
|
||||
: 0;
|
||||
pass_hist1d_covar = ((-covariance_eps_expect < covariance_eps) &&
|
||||
(covariance_eps_expect > covariance_eps))
|
||||
? 1
|
||||
: 0;
|
||||
|
||||
cout << "Density 1D: " << mean_eps << " " << variance_eps << " "
|
||||
<< (result.covariance / HIST_DIM1D / HIST_DIM1D) << " || "
|
||||
@ -371,8 +427,9 @@ struct test_random_scalar {
|
||||
test_histogram3d_functor<typename RandomGenerator::device_type>;
|
||||
parallel_reduce(HIST_DIM1D, functor_type(density_3d, num_draws), result);
|
||||
|
||||
double tolerance = 6 * std::sqrt(1.0 / HIST_DIM1D);
|
||||
double mean_expect = 1.0 * num_draws / HIST_DIM1D;
|
||||
double variance_factor = 1.2;
|
||||
double tolerance = 6 * std::sqrt(1.0 / HIST_DIM1D);
|
||||
double mean_expect = 1.0 * num_draws / HIST_DIM1D;
|
||||
double variance_expect =
|
||||
1.0 * num_draws / HIST_DIM1D * (1.0 - 1.0 / HIST_DIM1D);
|
||||
double covariance_expect = -1.0 * num_draws / HIST_DIM1D / HIST_DIM1D;
|
||||
@ -381,15 +438,23 @@ struct test_random_scalar {
|
||||
variance_expect / (result.variance / HIST_DIM1D) - 1.0;
|
||||
double covariance_eps =
|
||||
(result.covariance / HIST_DIM1D - covariance_expect) / mean_expect;
|
||||
|
||||
#if defined(KOKKOS_HALF_T_IS_FLOAT) && !KOKKOS_HALF_T_IS_FLOAT
|
||||
if (std::is_same<Scalar, Kokkos::Experimental::half_t>::value) {
|
||||
variance_factor = 7;
|
||||
}
|
||||
#endif
|
||||
|
||||
pass_hist3d_mean =
|
||||
((-tolerance < mean_eps) && (tolerance > mean_eps)) ? 1 : 0;
|
||||
pass_hist3d_var = ((-1.2 * tolerance < variance_eps) &&
|
||||
(1.2 * tolerance > variance_eps))
|
||||
pass_hist3d_var = ((-variance_factor * tolerance < variance_eps) &&
|
||||
(variance_factor * tolerance > variance_eps))
|
||||
? 1
|
||||
: 0;
|
||||
pass_hist3d_covar =
|
||||
((-tolerance < covariance_eps) && (tolerance > covariance_eps)) ? 1
|
||||
: 0;
|
||||
pass_hist3d_covar = ((-variance_factor * tolerance < covariance_eps) &&
|
||||
(variance_factor * tolerance > covariance_eps))
|
||||
? 1
|
||||
: 0;
|
||||
|
||||
cout << "Density 3D: " << mean_eps << " " << variance_eps << " "
|
||||
<< result.covariance / HIST_DIM1D / HIST_DIM1D << " || " << tolerance
|
||||
@ -471,6 +536,21 @@ void test_random(unsigned int num_draws) {
|
||||
deep_copy(density_1d, 0);
|
||||
deep_copy(density_3d, 0);
|
||||
|
||||
cout << "Test Scalar=half" << endl;
|
||||
test_random_scalar<RandomGenerator, Kokkos::Experimental::half_t> test_half(
|
||||
density_1d, density_3d, pool, num_draws);
|
||||
ASSERT_EQ(test_half.pass_mean, 1);
|
||||
ASSERT_EQ(test_half.pass_var, 1);
|
||||
ASSERT_EQ(test_half.pass_covar, 1);
|
||||
ASSERT_EQ(test_half.pass_hist1d_mean, 1);
|
||||
ASSERT_EQ(test_half.pass_hist1d_var, 1);
|
||||
ASSERT_EQ(test_half.pass_hist1d_covar, 1);
|
||||
ASSERT_EQ(test_half.pass_hist3d_mean, 1);
|
||||
ASSERT_EQ(test_half.pass_hist3d_var, 1);
|
||||
ASSERT_EQ(test_half.pass_hist3d_covar, 1);
|
||||
deep_copy(density_1d, 0);
|
||||
deep_copy(density_3d, 0);
|
||||
|
||||
cout << "Test Scalar=float" << endl;
|
||||
test_random_scalar<RandomGenerator, float> test_float(density_1d, density_3d,
|
||||
pool, num_draws);
|
||||
|
||||
Reference in New Issue
Block a user