Updating Kokkos lib
This commit is contained in:
@ -1,6 +1,6 @@
|
||||
|
||||
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR})
|
||||
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR})
|
||||
INCLUDE_DIRECTORIES(REQUIRED_DURING_INSTALLATION_TESTING ${CMAKE_CURRENT_SOURCE_DIR})
|
||||
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/../src )
|
||||
|
||||
SET(SOURCES
|
||||
|
||||
@ -7,21 +7,18 @@ vpath %.cpp ${KOKKOS_PATH}/containers/unit_tests
|
||||
default: build_all
|
||||
echo "End Build"
|
||||
|
||||
ifneq (,$(findstring Cuda,$(KOKKOS_DEVICES)))
|
||||
CXX = $(KOKKOS_PATH)/config/nvcc_wrapper
|
||||
else
|
||||
CXX = g++
|
||||
endif
|
||||
|
||||
CXXFLAGS = -O3
|
||||
LINK ?= $(CXX)
|
||||
LDFLAGS ?= -lpthread
|
||||
|
||||
include $(KOKKOS_PATH)/Makefile.kokkos
|
||||
|
||||
ifeq ($(KOKKOS_INTERNAL_USE_CUDA), 1)
|
||||
CXX = $(NVCC_WRAPPER)
|
||||
CXXFLAGS ?= -O3
|
||||
LINK = $(CXX)
|
||||
LDFLAGS ?= -lpthread
|
||||
else
|
||||
CXX ?= g++
|
||||
CXXFLAGS ?= -O3
|
||||
LINK ?= $(CXX)
|
||||
LDFLAGS ?= -lpthread
|
||||
endif
|
||||
|
||||
KOKKOS_CXXFLAGS += -I$(GTEST_PATH) -I${KOKKOS_PATH}/containers/unit_tests
|
||||
|
||||
TEST_TARGETS =
|
||||
|
||||
@ -59,11 +59,13 @@
|
||||
#include <TestVector.hpp>
|
||||
#include <TestDualView.hpp>
|
||||
#include <TestDynamicView.hpp>
|
||||
#include <TestSegmentedView.hpp>
|
||||
|
||||
#include <Kokkos_DynRankView.hpp>
|
||||
#include <TestDynViewAPI.hpp>
|
||||
|
||||
#include <Kokkos_ErrorReporter.hpp>
|
||||
#include <TestErrorReporter.hpp>
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
|
||||
@ -133,11 +135,6 @@ void cuda_test_dualview_combinations(unsigned int size)
|
||||
test_dualview_combinations<int,Kokkos::Cuda>(size);
|
||||
}
|
||||
|
||||
void cuda_test_segmented_view(unsigned int size)
|
||||
{
|
||||
test_segmented_view<double,Kokkos::Cuda>(size);
|
||||
}
|
||||
|
||||
void cuda_test_bitset()
|
||||
{
|
||||
test_bitset<Kokkos::Cuda>();
|
||||
@ -184,11 +181,6 @@ void cuda_test_bitset()
|
||||
cuda_test_dualview_combinations(size); \
|
||||
}
|
||||
|
||||
#define CUDA_SEGMENTEDVIEW_TEST( size ) \
|
||||
TEST_F( cuda, segmentedview_##size##x) { \
|
||||
cuda_test_segmented_view(size); \
|
||||
}
|
||||
|
||||
CUDA_DUALVIEW_COMBINE_TEST( 10 )
|
||||
CUDA_VECTOR_COMBINE_TEST( 10 )
|
||||
CUDA_VECTOR_COMBINE_TEST( 3057 )
|
||||
@ -198,7 +190,6 @@ CUDA_INSERT_TEST(close, 100000, 90000, 100, 500)
|
||||
CUDA_INSERT_TEST(far, 100000, 90000, 100, 500)
|
||||
CUDA_DEEP_COPY( 10000, 1 )
|
||||
CUDA_FAILED_INSERT_TEST( 10000, 1000 )
|
||||
CUDA_SEGMENTEDVIEW_TEST( 200 )
|
||||
|
||||
|
||||
#undef CUDA_INSERT_TEST
|
||||
@ -207,7 +198,6 @@ CUDA_SEGMENTEDVIEW_TEST( 200 )
|
||||
#undef CUDA_DEEP_COPY
|
||||
#undef CUDA_VECTOR_COMBINE_TEST
|
||||
#undef CUDA_DUALVIEW_COMBINE_TEST
|
||||
#undef CUDA_SEGMENTEDVIEW_TEST
|
||||
|
||||
|
||||
TEST_F( cuda , dynamic_view )
|
||||
@ -221,6 +211,18 @@ TEST_F( cuda , dynamic_view )
|
||||
}
|
||||
|
||||
|
||||
#if defined(KOKKOS_CLASS_LAMBDA)
|
||||
TEST_F(cuda, ErrorReporterViaLambda)
|
||||
{
|
||||
TestErrorReporter<ErrorReporterDriverUseLambda<Kokkos::Cuda>>();
|
||||
}
|
||||
#endif
|
||||
|
||||
TEST_F(cuda, ErrorReporter)
|
||||
{
|
||||
TestErrorReporter<ErrorReporterDriver<Kokkos::Cuda>>();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif /* #ifdef KOKKOS_HAVE_CUDA */
|
||||
|
||||
@ -715,9 +715,9 @@ public:
|
||||
typedef Kokkos::Experimental::DynRankView< T, device, Kokkos::MemoryUnmanaged > dView0_unmanaged ;
|
||||
typedef typename dView0::host_mirror_space host_drv_space ;
|
||||
|
||||
typedef Kokkos::Experimental::View< T , device > View0 ;
|
||||
typedef Kokkos::Experimental::View< T* , device > View1 ;
|
||||
typedef Kokkos::Experimental::View< T******* , device > View7 ;
|
||||
typedef Kokkos::View< T , device > View0 ;
|
||||
typedef Kokkos::View< T* , device > View1 ;
|
||||
typedef Kokkos::View< T******* , device > View7 ;
|
||||
|
||||
typedef typename View0::host_mirror_space host_view_space ;
|
||||
|
||||
@ -1127,8 +1127,7 @@ public:
|
||||
// T v2 = hx(0,0) ; // Generates compile error as intended
|
||||
// hx(0,0) = v2 ; // Generates compile error as intended
|
||||
|
||||
/*
|
||||
#if ! KOKKOS_USING_EXP_VIEW
|
||||
#if 0 /* Asynchronous deep copies not implemented for dynamic rank view */
|
||||
// Testing with asynchronous deep copy with respect to device
|
||||
{
|
||||
size_t count = 0 ;
|
||||
@ -1193,7 +1192,7 @@ public:
|
||||
{ ASSERT_EQ( hx(ip,i1,i2,i3) , T(0) ); }
|
||||
}}}}
|
||||
}
|
||||
#endif */ // #if ! KOKKOS_USING_EXP_VIEW
|
||||
#endif
|
||||
|
||||
// Testing with synchronous deep copy
|
||||
{
|
||||
|
||||
227
lib/kokkos/containers/unit_tests/TestErrorReporter.hpp
Normal file
227
lib/kokkos/containers/unit_tests/TestErrorReporter.hpp
Normal file
@ -0,0 +1,227 @@
|
||||
/*
|
||||
//@HEADER
|
||||
// ************************************************************************
|
||||
//
|
||||
// Kokkos v. 2.0
|
||||
// Copyright (2014) Sandia Corporation
|
||||
//
|
||||
// Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
|
||||
// the U.S. Government retains certain rights in this software.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are
|
||||
// met:
|
||||
//
|
||||
// 1. Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// 2. Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
//
|
||||
// 3. Neither the name of the Corporation nor the names of the
|
||||
// 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
|
||||
// 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
|
||||
// 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
|
||||
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Questions? Contact H. Carter Edwards (hcedwar@sandia.gov)
|
||||
//
|
||||
// ************************************************************************
|
||||
//@HEADER
|
||||
*/
|
||||
|
||||
#ifndef KOKKOS_TEST_EXPERIMENTAL_ERROR_REPORTER_HPP
|
||||
#define KOKKOS_TEST_EXPERIMENTAL_ERROR_REPORTER_HPP
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
#include <iostream>
|
||||
#include <Kokkos_Core.hpp>
|
||||
|
||||
namespace Test {
|
||||
|
||||
// Just save the data in the report. Informative text goies in the operator<<(..).
|
||||
template <typename DataType1, typename DataType2, typename DataType3>
|
||||
struct ThreeValReport
|
||||
{
|
||||
DataType1 m_data1;
|
||||
DataType2 m_data2;
|
||||
DataType3 m_data3;
|
||||
|
||||
};
|
||||
|
||||
template <typename DataType1, typename DataType2, typename DataType3>
|
||||
std::ostream &operator<<(std::ostream & os, const ThreeValReport<DataType1, DataType2, DataType3> &val)
|
||||
{
|
||||
return os << "{" << val.m_data1 << " " << val.m_data2 << " " << val.m_data3 << "}";
|
||||
}
|
||||
|
||||
template<typename ReportType>
|
||||
void checkReportersAndReportsAgree(const std::vector<int> &reporters,
|
||||
const std::vector<ReportType> &reports)
|
||||
{
|
||||
for (size_t i = 0; i < reports.size(); ++i) {
|
||||
EXPECT_EQ(1, reporters[i] % 2);
|
||||
EXPECT_EQ(reporters[i], reports[i].m_data1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template <typename DeviceType>
|
||||
struct ErrorReporterDriverBase {
|
||||
|
||||
typedef ThreeValReport<int, int, double> report_type;
|
||||
typedef Kokkos::Experimental::ErrorReporter<report_type, DeviceType> error_reporter_type;
|
||||
error_reporter_type m_errorReporter;
|
||||
|
||||
ErrorReporterDriverBase(int reporter_capacity, int test_size)
|
||||
: m_errorReporter(reporter_capacity) { }
|
||||
|
||||
KOKKOS_INLINE_FUNCTION bool error_condition(const int work_idx) const { return (work_idx % 2 != 0); }
|
||||
|
||||
void check_expectations(int reporter_capacity, int test_size)
|
||||
{
|
||||
int num_reported = m_errorReporter.getNumReports();
|
||||
int num_attempts = m_errorReporter.getNumReportAttempts();
|
||||
|
||||
int expected_num_reports = std::min(reporter_capacity, test_size / 2);
|
||||
EXPECT_EQ(expected_num_reports, num_reported);
|
||||
EXPECT_EQ(test_size / 2, num_attempts);
|
||||
|
||||
bool expect_full = (reporter_capacity <= (test_size / 2));
|
||||
bool reported_full = m_errorReporter.full();
|
||||
EXPECT_EQ(expect_full, reported_full);
|
||||
}
|
||||
};
|
||||
|
||||
template <typename ErrorReporterDriverType>
|
||||
void TestErrorReporter()
|
||||
{
|
||||
typedef ErrorReporterDriverType tester_type;
|
||||
std::vector<int> reporters;
|
||||
std::vector<typename tester_type::report_type> reports;
|
||||
|
||||
tester_type test1(100, 10);
|
||||
test1.m_errorReporter.getReports(reporters, reports);
|
||||
checkReportersAndReportsAgree(reporters, reports);
|
||||
|
||||
tester_type test2(10, 100);
|
||||
test2.m_errorReporter.getReports(reporters, reports);
|
||||
checkReportersAndReportsAgree(reporters, reports);
|
||||
|
||||
typename Kokkos::View<int*, typename ErrorReporterDriverType::execution_space >::HostMirror view_reporters;
|
||||
typename Kokkos::View<typename tester_type::report_type*, typename ErrorReporterDriverType::execution_space >::HostMirror
|
||||
view_reports;
|
||||
test2.m_errorReporter.getReports(view_reporters, view_reports);
|
||||
|
||||
int num_reports = view_reporters.extent(0);
|
||||
reporters.clear();
|
||||
reports.clear();
|
||||
reporters.reserve(num_reports);
|
||||
reports.reserve(num_reports);
|
||||
|
||||
for (int i = 0; i < num_reports; ++i) {
|
||||
reporters.push_back(view_reporters(i));
|
||||
reports.push_back(view_reports(i));
|
||||
}
|
||||
checkReportersAndReportsAgree(reporters, reports);
|
||||
|
||||
}
|
||||
|
||||
|
||||
template <typename DeviceType>
|
||||
struct ErrorReporterDriver : public ErrorReporterDriverBase<DeviceType>
|
||||
{
|
||||
typedef ErrorReporterDriverBase<DeviceType> driver_base;
|
||||
typedef typename driver_base::error_reporter_type::execution_space execution_space;
|
||||
|
||||
ErrorReporterDriver(int reporter_capacity, int test_size)
|
||||
: driver_base(reporter_capacity, test_size)
|
||||
{
|
||||
execute(reporter_capacity, test_size);
|
||||
|
||||
// Test that clear() and resize() work across memory spaces.
|
||||
if (reporter_capacity < test_size) {
|
||||
driver_base::m_errorReporter.clear();
|
||||
driver_base::m_errorReporter.resize(test_size);
|
||||
execute(test_size, test_size);
|
||||
}
|
||||
}
|
||||
|
||||
void execute(int reporter_capacity, int test_size)
|
||||
{
|
||||
Kokkos::parallel_for(Kokkos::RangePolicy<execution_space>(0,test_size), *this);
|
||||
driver_base::check_expectations(reporter_capacity, test_size);
|
||||
}
|
||||
|
||||
KOKKOS_INLINE_FUNCTION
|
||||
void operator()(const int work_idx) const
|
||||
{
|
||||
if (driver_base::error_condition(work_idx)) {
|
||||
double val = M_PI * static_cast<double>(work_idx);
|
||||
typename driver_base::report_type report = {work_idx, -2*work_idx, val};
|
||||
driver_base::m_errorReporter.add_report(work_idx, report);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
#if defined(KOKKOS_CLASS_LAMBDA)
|
||||
template <typename DeviceType>
|
||||
struct ErrorReporterDriverUseLambda : public ErrorReporterDriverBase<DeviceType>
|
||||
{
|
||||
|
||||
typedef ErrorReporterDriverBase<DeviceType> driver_base;
|
||||
typedef typename driver_base::error_reporter_type::execution_space execution_space;
|
||||
|
||||
ErrorReporterDriverUseLambda(int reporter_capacity, int test_size)
|
||||
: driver_base(reporter_capacity, test_size)
|
||||
{
|
||||
Kokkos::parallel_for(Kokkos::RangePolicy<execution_space>(0,test_size), KOKKOS_CLASS_LAMBDA (const int work_idx) {
|
||||
if (driver_base::error_condition(work_idx)) {
|
||||
double val = M_PI * static_cast<double>(work_idx);
|
||||
typename driver_base::report_type report = {work_idx, -2*work_idx, val};
|
||||
driver_base::m_errorReporter.add_report(work_idx, report);
|
||||
}
|
||||
});
|
||||
driver_base::check_expectations(reporter_capacity, test_size);
|
||||
}
|
||||
|
||||
};
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef KOKKOS_HAVE_OPENMP
|
||||
struct ErrorReporterDriverNativeOpenMP : public ErrorReporterDriverBase<Kokkos::OpenMP>
|
||||
{
|
||||
typedef ErrorReporterDriverBase<Kokkos::OpenMP> driver_base;
|
||||
typedef typename driver_base::error_reporter_type::execution_space execution_space;
|
||||
|
||||
ErrorReporterDriverNativeOpenMP(int reporter_capacity, int test_size)
|
||||
: driver_base(reporter_capacity, test_size)
|
||||
{
|
||||
#pragma omp parallel for
|
||||
for(int work_idx = 0; work_idx < test_size; ++work_idx)
|
||||
{
|
||||
if (driver_base::error_condition(work_idx)) {
|
||||
double val = M_PI * static_cast<double>(work_idx);
|
||||
typename driver_base::report_type report = {work_idx, -2*work_idx, val};
|
||||
driver_base::m_errorReporter.add_report(work_idx, report);
|
||||
}
|
||||
};
|
||||
driver_base::check_expectations(reporter_capacity, test_size);
|
||||
}
|
||||
};
|
||||
#endif
|
||||
|
||||
} // namespace Test
|
||||
#endif // #ifndef KOKKOS_TEST_ERROR_REPORTING_HPP
|
||||
@ -56,12 +56,14 @@
|
||||
#include <TestVector.hpp>
|
||||
#include <TestDualView.hpp>
|
||||
#include <TestDynamicView.hpp>
|
||||
#include <TestSegmentedView.hpp>
|
||||
#include <TestComplex.hpp>
|
||||
|
||||
#include <Kokkos_DynRankView.hpp>
|
||||
#include <TestDynViewAPI.hpp>
|
||||
|
||||
#include <Kokkos_ErrorReporter.hpp>
|
||||
#include <TestErrorReporter.hpp>
|
||||
|
||||
#include <iomanip>
|
||||
|
||||
namespace Test {
|
||||
@ -143,11 +145,6 @@ TEST_F( openmp , staticcrsgraph )
|
||||
test_dualview_combinations<int,Kokkos::OpenMP>(size); \
|
||||
}
|
||||
|
||||
#define OPENMP_SEGMENTEDVIEW_TEST( size ) \
|
||||
TEST_F( openmp, segmentedview_##size##x) { \
|
||||
test_segmented_view<double,Kokkos::OpenMP>(size); \
|
||||
}
|
||||
|
||||
OPENMP_INSERT_TEST(close, 100000, 90000, 100, 500, true)
|
||||
OPENMP_INSERT_TEST(far, 100000, 90000, 100, 500, false)
|
||||
OPENMP_FAILED_INSERT_TEST( 10000, 1000 )
|
||||
@ -156,7 +153,6 @@ OPENMP_DEEP_COPY( 10000, 1 )
|
||||
OPENMP_VECTOR_COMBINE_TEST( 10 )
|
||||
OPENMP_VECTOR_COMBINE_TEST( 3057 )
|
||||
OPENMP_DUALVIEW_COMBINE_TEST( 10 )
|
||||
OPENMP_SEGMENTEDVIEW_TEST( 10000 )
|
||||
|
||||
#undef OPENMP_INSERT_TEST
|
||||
#undef OPENMP_FAILED_INSERT_TEST
|
||||
@ -164,7 +160,6 @@ OPENMP_SEGMENTEDVIEW_TEST( 10000 )
|
||||
#undef OPENMP_DEEP_COPY
|
||||
#undef OPENMP_VECTOR_COMBINE_TEST
|
||||
#undef OPENMP_DUALVIEW_COMBINE_TEST
|
||||
#undef OPENMP_SEGMENTEDVIEW_TEST
|
||||
#endif
|
||||
|
||||
|
||||
@ -178,5 +173,22 @@ TEST_F( openmp , dynamic_view )
|
||||
}
|
||||
}
|
||||
|
||||
#if defined(KOKKOS_CLASS_LAMBDA)
|
||||
TEST_F(openmp, ErrorReporterViaLambda)
|
||||
{
|
||||
TestErrorReporter<ErrorReporterDriverUseLambda<Kokkos::OpenMP>>();
|
||||
}
|
||||
#endif
|
||||
|
||||
TEST_F(openmp, ErrorReporter)
|
||||
{
|
||||
TestErrorReporter<ErrorReporterDriver<Kokkos::OpenMP>>();
|
||||
}
|
||||
|
||||
TEST_F(openmp, ErrorReporterNativeOpenMP)
|
||||
{
|
||||
TestErrorReporter<ErrorReporterDriverNativeOpenMP>();
|
||||
}
|
||||
|
||||
} // namespace test
|
||||
|
||||
|
||||
@ -1,708 +0,0 @@
|
||||
/*
|
||||
//@HEADER
|
||||
// ************************************************************************
|
||||
//
|
||||
// Kokkos v. 2.0
|
||||
// Copyright (2014) Sandia Corporation
|
||||
//
|
||||
// Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
|
||||
// the U.S. Government retains certain rights in this software.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are
|
||||
// met:
|
||||
//
|
||||
// 1. Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// 2. Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
//
|
||||
// 3. Neither the name of the Corporation nor the names of the
|
||||
// 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
|
||||
// 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
|
||||
// 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
|
||||
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Questions? Contact H. Carter Edwards (hcedwar@sandia.gov)
|
||||
//
|
||||
// ************************************************************************
|
||||
//@HEADER
|
||||
*/
|
||||
|
||||
#ifndef KOKKOS_TEST_SEGMENTEDVIEW_HPP
|
||||
#define KOKKOS_TEST_SEGMENTEDVIEW_HPP
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
#include <iostream>
|
||||
#include <cstdlib>
|
||||
#include <cstdio>
|
||||
#include <Kokkos_Core.hpp>
|
||||
|
||||
#if ! KOKKOS_USING_EXP_VIEW
|
||||
|
||||
#include <Kokkos_SegmentedView.hpp>
|
||||
#include <impl/Kokkos_Timer.hpp>
|
||||
|
||||
namespace Test {
|
||||
|
||||
namespace Impl {
|
||||
|
||||
template<class ViewType , class ExecutionSpace, int Rank = ViewType::Rank>
|
||||
struct GrowTest;
|
||||
|
||||
template<class ViewType , class ExecutionSpace>
|
||||
struct GrowTest<ViewType , ExecutionSpace , 1> {
|
||||
typedef ExecutionSpace execution_space;
|
||||
typedef Kokkos::TeamPolicy<execution_space> Policy;
|
||||
typedef typename Policy::member_type team_type;
|
||||
typedef double value_type;
|
||||
|
||||
ViewType a;
|
||||
|
||||
GrowTest(ViewType in):a(in) {}
|
||||
|
||||
KOKKOS_INLINE_FUNCTION
|
||||
void operator() (team_type team_member, double& value) const {
|
||||
unsigned int team_idx = team_member.league_rank() * team_member.team_size();
|
||||
|
||||
a.grow(team_member , team_idx+team_member.team_size());
|
||||
value += team_idx + team_member.team_rank();
|
||||
|
||||
if((a.dimension_0()>team_idx+team_member.team_rank()) &&
|
||||
(a.dimension(0)>team_idx+team_member.team_rank()))
|
||||
a(team_idx+team_member.team_rank()) = team_idx+team_member.team_rank();
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
template<class ViewType , class ExecutionSpace>
|
||||
struct GrowTest<ViewType , ExecutionSpace , 2> {
|
||||
typedef ExecutionSpace execution_space;
|
||||
typedef Kokkos::TeamPolicy<execution_space> Policy;
|
||||
typedef typename Policy::member_type team_type;
|
||||
typedef double value_type;
|
||||
|
||||
ViewType a;
|
||||
|
||||
GrowTest(ViewType in):a(in) {}
|
||||
|
||||
KOKKOS_INLINE_FUNCTION
|
||||
void operator() (team_type team_member, double& value) const {
|
||||
unsigned int team_idx = team_member.league_rank() * team_member.team_size();
|
||||
|
||||
a.grow(team_member , team_idx+ team_member.team_size());
|
||||
|
||||
for( typename ExecutionSpace::size_type k=0;k<7;k++)
|
||||
value += team_idx + team_member.team_rank() + 13*k;
|
||||
|
||||
if((a.dimension_0()>team_idx+ team_member.team_rank()) &&
|
||||
(a.dimension(0)>team_idx+ team_member.team_rank())) {
|
||||
for( typename ExecutionSpace::size_type k=0;k<a.dimension_1();k++) {
|
||||
a(team_idx+ team_member.team_rank(),k) =
|
||||
team_idx+ team_member.team_rank() + 13*k;
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
template<class ViewType , class ExecutionSpace>
|
||||
struct GrowTest<ViewType , ExecutionSpace , 3> {
|
||||
typedef ExecutionSpace execution_space;
|
||||
typedef Kokkos::TeamPolicy<execution_space> Policy;
|
||||
typedef typename Policy::member_type team_type;
|
||||
typedef double value_type;
|
||||
|
||||
ViewType a;
|
||||
|
||||
GrowTest(ViewType in):a(in) {}
|
||||
|
||||
KOKKOS_INLINE_FUNCTION
|
||||
void operator() (team_type team_member, double& value) const {
|
||||
unsigned int team_idx = team_member.league_rank() * team_member.team_size();
|
||||
|
||||
a.grow(team_member , team_idx+ team_member.team_size());
|
||||
|
||||
for( typename ExecutionSpace::size_type k=0;k<7;k++)
|
||||
for( typename ExecutionSpace::size_type l=0;l<3;l++)
|
||||
value += team_idx + team_member.team_rank() + 13*k + 3*l;
|
||||
|
||||
if((a.dimension_0()>team_idx+ team_member.team_rank()) &&
|
||||
(a.dimension(0)>team_idx+ team_member.team_rank())) {
|
||||
for( typename ExecutionSpace::size_type k=0;k<a.dimension_1();k++)
|
||||
for( typename ExecutionSpace::size_type l=0;l<a.dimension_2();l++)
|
||||
a(team_idx+ team_member.team_rank(),k,l) =
|
||||
team_idx+ team_member.team_rank() + 13*k + 3*l;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
template<class ViewType , class ExecutionSpace>
|
||||
struct GrowTest<ViewType , ExecutionSpace , 4> {
|
||||
typedef ExecutionSpace execution_space;
|
||||
typedef Kokkos::TeamPolicy<execution_space> Policy;
|
||||
typedef typename Policy::member_type team_type;
|
||||
typedef double value_type;
|
||||
|
||||
ViewType a;
|
||||
|
||||
GrowTest(ViewType in):a(in) {}
|
||||
|
||||
KOKKOS_INLINE_FUNCTION
|
||||
void operator() (team_type team_member, double& value) const {
|
||||
unsigned int team_idx = team_member.league_rank() * team_member.team_size();
|
||||
|
||||
a.grow(team_member , team_idx+ team_member.team_size());
|
||||
|
||||
for( typename ExecutionSpace::size_type k=0;k<7;k++)
|
||||
for( typename ExecutionSpace::size_type l=0;l<3;l++)
|
||||
for( typename ExecutionSpace::size_type m=0;m<2;m++)
|
||||
value += team_idx + team_member.team_rank() + 13*k + 3*l + 7*m;
|
||||
|
||||
if((a.dimension_0()>team_idx+ team_member.team_rank()) &&
|
||||
(a.dimension(0)>team_idx+ team_member.team_rank())) {
|
||||
for( typename ExecutionSpace::size_type k=0;k<a.dimension_1();k++)
|
||||
for( typename ExecutionSpace::size_type l=0;l<a.dimension_2();l++)
|
||||
for( typename ExecutionSpace::size_type m=0;m<a.dimension_3();m++)
|
||||
a(team_idx+ team_member.team_rank(),k,l,m) =
|
||||
team_idx+ team_member.team_rank() + 13*k + 3*l + 7*m;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
template<class ViewType , class ExecutionSpace>
|
||||
struct GrowTest<ViewType , ExecutionSpace , 5> {
|
||||
typedef ExecutionSpace execution_space;
|
||||
typedef Kokkos::TeamPolicy<execution_space> Policy;
|
||||
typedef typename Policy::member_type team_type;
|
||||
typedef double value_type;
|
||||
|
||||
ViewType a;
|
||||
|
||||
GrowTest(ViewType in):a(in) {}
|
||||
|
||||
KOKKOS_INLINE_FUNCTION
|
||||
void operator() (team_type team_member, double& value) const {
|
||||
unsigned int team_idx = team_member.league_rank() * team_member.team_size();
|
||||
|
||||
a.grow(team_member , team_idx+ team_member.team_size());
|
||||
|
||||
for( typename ExecutionSpace::size_type k=0;k<7;k++)
|
||||
for( typename ExecutionSpace::size_type l=0;l<3;l++)
|
||||
for( typename ExecutionSpace::size_type m=0;m<2;m++)
|
||||
for( typename ExecutionSpace::size_type n=0;n<3;n++)
|
||||
value +=
|
||||
team_idx + team_member.team_rank() + 13*k + 3*l + 7*m + 5*n;
|
||||
|
||||
if((a.dimension_0()>team_idx+ team_member.team_rank()) &&
|
||||
(a.dimension(0)>team_idx+ team_member.team_rank())) {
|
||||
for( typename ExecutionSpace::size_type k=0;k<a.dimension_1();k++)
|
||||
for( typename ExecutionSpace::size_type l=0;l<a.dimension_2();l++)
|
||||
for( typename ExecutionSpace::size_type m=0;m<a.dimension_3();m++)
|
||||
for( typename ExecutionSpace::size_type n=0;n<a.dimension_4();n++)
|
||||
a(team_idx+ team_member.team_rank(),k,l,m,n) =
|
||||
team_idx+ team_member.team_rank() + 13*k + 3*l + 7*m + 5*n;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
template<class ViewType , class ExecutionSpace>
|
||||
struct GrowTest<ViewType , ExecutionSpace , 6> {
|
||||
typedef ExecutionSpace execution_space;
|
||||
typedef Kokkos::TeamPolicy<execution_space> Policy;
|
||||
typedef typename Policy::member_type team_type;
|
||||
typedef double value_type;
|
||||
|
||||
ViewType a;
|
||||
|
||||
GrowTest(ViewType in):a(in) {}
|
||||
|
||||
KOKKOS_INLINE_FUNCTION
|
||||
void operator() (team_type team_member, double& value) const {
|
||||
unsigned int team_idx = team_member.league_rank() * team_member.team_size();
|
||||
|
||||
a.grow(team_member , team_idx+ team_member.team_size());
|
||||
|
||||
for( typename ExecutionSpace::size_type k=0;k<7;k++)
|
||||
for( typename ExecutionSpace::size_type l=0;l<3;l++)
|
||||
for( typename ExecutionSpace::size_type m=0;m<2;m++)
|
||||
for( typename ExecutionSpace::size_type n=0;n<3;n++)
|
||||
for( typename ExecutionSpace::size_type o=0;o<2;o++)
|
||||
value +=
|
||||
team_idx + team_member.team_rank() + 13*k + 3*l + 7*m + 5*n + 2*o ;
|
||||
|
||||
if((a.dimension_0()>team_idx+ team_member.team_rank()) &&
|
||||
(a.dimension(0)>team_idx+ team_member.team_rank())) {
|
||||
for( typename ExecutionSpace::size_type k=0;k<a.dimension_1();k++)
|
||||
for( typename ExecutionSpace::size_type l=0;l<a.dimension_2();l++)
|
||||
for( typename ExecutionSpace::size_type m=0;m<a.dimension_3();m++)
|
||||
for( typename ExecutionSpace::size_type n=0;n<a.dimension_4();n++)
|
||||
for( typename ExecutionSpace::size_type o=0;o<a.dimension_5();o++)
|
||||
a(team_idx+ team_member.team_rank(),k,l,m,n,o) =
|
||||
team_idx + team_member.team_rank() + 13*k + 3*l + 7*m + 5*n + 2*o ;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
template<class ViewType , class ExecutionSpace>
|
||||
struct GrowTest<ViewType , ExecutionSpace , 7> {
|
||||
typedef ExecutionSpace execution_space;
|
||||
typedef Kokkos::TeamPolicy<execution_space> Policy;
|
||||
typedef typename Policy::member_type team_type;
|
||||
typedef double value_type;
|
||||
|
||||
ViewType a;
|
||||
|
||||
GrowTest(ViewType in):a(in) {}
|
||||
|
||||
KOKKOS_INLINE_FUNCTION
|
||||
void operator() (team_type team_member, double& value) const {
|
||||
unsigned int team_idx = team_member.league_rank() * team_member.team_size();
|
||||
|
||||
a.grow(team_member , team_idx+ team_member.team_size());
|
||||
|
||||
for( typename ExecutionSpace::size_type k=0;k<7;k++)
|
||||
for( typename ExecutionSpace::size_type l=0;l<3;l++)
|
||||
for( typename ExecutionSpace::size_type m=0;m<2;m++)
|
||||
for( typename ExecutionSpace::size_type n=0;n<3;n++)
|
||||
for( typename ExecutionSpace::size_type o=0;o<2;o++)
|
||||
for( typename ExecutionSpace::size_type p=0;p<4;p++)
|
||||
value +=
|
||||
team_idx + team_member.team_rank() + 13*k + 3*l + 7*m + 5*n + 2*o + 15*p ;
|
||||
|
||||
if((a.dimension_0()>team_idx+ team_member.team_rank()) &&
|
||||
(a.dimension(0)>team_idx+ team_member.team_rank())) {
|
||||
for( typename ExecutionSpace::size_type k=0;k<a.dimension_1();k++)
|
||||
for( typename ExecutionSpace::size_type l=0;l<a.dimension_2();l++)
|
||||
for( typename ExecutionSpace::size_type m=0;m<a.dimension_3();m++)
|
||||
for( typename ExecutionSpace::size_type n=0;n<a.dimension_4();n++)
|
||||
for( typename ExecutionSpace::size_type o=0;o<a.dimension_5();o++)
|
||||
for( typename ExecutionSpace::size_type p=0;p<a.dimension_6();p++)
|
||||
a(team_idx+ team_member.team_rank(),k,l,m,n,o,p) =
|
||||
team_idx + team_member.team_rank() + 13*k + 3*l + 7*m + 5*n + 2*o + 15*p ;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
template<class ViewType , class ExecutionSpace>
|
||||
struct GrowTest<ViewType , ExecutionSpace , 8> {
|
||||
typedef ExecutionSpace execution_space;
|
||||
typedef Kokkos::TeamPolicy<execution_space> Policy;
|
||||
typedef typename Policy::member_type team_type;
|
||||
typedef double value_type;
|
||||
|
||||
ViewType a;
|
||||
|
||||
GrowTest(ViewType in):a(in) {}
|
||||
|
||||
KOKKOS_INLINE_FUNCTION
|
||||
void operator() (team_type team_member, double& value) const {
|
||||
unsigned int team_idx = team_member.league_rank() * team_member.team_size();
|
||||
a.grow(team_member , team_idx + team_member.team_size());
|
||||
|
||||
for( typename ExecutionSpace::size_type k=0;k<7;k++)
|
||||
for( typename ExecutionSpace::size_type l=0;l<3;l++)
|
||||
for( typename ExecutionSpace::size_type m=0;m<2;m++)
|
||||
for( typename ExecutionSpace::size_type n=0;n<3;n++)
|
||||
for( typename ExecutionSpace::size_type o=0;o<2;o++)
|
||||
for( typename ExecutionSpace::size_type p=0;p<4;p++)
|
||||
for( typename ExecutionSpace::size_type q=0;q<3;q++)
|
||||
value +=
|
||||
team_idx + team_member.team_rank() + 13*k + 3*l + 7*m + 5*n + 2*o + 15*p + 17*q;
|
||||
|
||||
if((a.dimension_0()>team_idx+ team_member.team_rank()) &&
|
||||
(a.dimension(0)>team_idx+ team_member.team_rank())) {
|
||||
for( typename ExecutionSpace::size_type k=0;k<a.dimension_1();k++)
|
||||
for( typename ExecutionSpace::size_type l=0;l<a.dimension_2();l++)
|
||||
for( typename ExecutionSpace::size_type m=0;m<a.dimension_3();m++)
|
||||
for( typename ExecutionSpace::size_type n=0;n<a.dimension_4();n++)
|
||||
for( typename ExecutionSpace::size_type o=0;o<a.dimension_5();o++)
|
||||
for( typename ExecutionSpace::size_type p=0;p<a.dimension_6();p++)
|
||||
for( typename ExecutionSpace::size_type q=0;q<a.dimension_7();q++)
|
||||
a(team_idx+ team_member.team_rank(),k,l,m,n,o,p,q) =
|
||||
team_idx + team_member.team_rank() + 13*k + 3*l + 7*m + 5*n + 2*o + 15*p + 17*q;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
template<class ViewType , class ExecutionSpace, int Rank = ViewType::Rank>
|
||||
struct VerifyTest;
|
||||
|
||||
template<class ViewType , class ExecutionSpace>
|
||||
struct VerifyTest<ViewType , ExecutionSpace , 1> {
|
||||
typedef ExecutionSpace execution_space;
|
||||
typedef Kokkos::TeamPolicy<execution_space> Policy;
|
||||
typedef typename Policy::member_type team_type;
|
||||
typedef double value_type;
|
||||
|
||||
ViewType a;
|
||||
|
||||
VerifyTest(ViewType in):a(in) {}
|
||||
|
||||
KOKKOS_INLINE_FUNCTION
|
||||
void operator() (team_type team_member, double& value) const {
|
||||
unsigned int team_idx = team_member.league_rank() * team_member.team_size();
|
||||
|
||||
if((a.dimension_0()>team_idx+ team_member.team_rank()) &&
|
||||
(a.dimension(0)>team_idx+ team_member.team_rank())) {
|
||||
value += a(team_idx+ team_member.team_rank());
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
template<class ViewType , class ExecutionSpace>
|
||||
struct VerifyTest<ViewType , ExecutionSpace , 2> {
|
||||
typedef ExecutionSpace execution_space;
|
||||
typedef Kokkos::TeamPolicy<execution_space> Policy;
|
||||
typedef typename Policy::member_type team_type;
|
||||
typedef double value_type;
|
||||
|
||||
ViewType a;
|
||||
|
||||
VerifyTest(ViewType in):a(in) {}
|
||||
|
||||
KOKKOS_INLINE_FUNCTION
|
||||
void operator() (team_type team_member, double& value) const {
|
||||
unsigned int team_idx = team_member.league_rank() * team_member.team_size();
|
||||
|
||||
if((a.dimension_0()>team_idx+ team_member.team_rank()) &&
|
||||
(a.dimension(0)>team_idx+ team_member.team_rank())) {
|
||||
for( typename ExecutionSpace::size_type k=0;k<a.dimension_1();k++)
|
||||
value += a(team_idx+ team_member.team_rank(),k);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
template<class ViewType , class ExecutionSpace>
|
||||
struct VerifyTest<ViewType , ExecutionSpace , 3> {
|
||||
typedef ExecutionSpace execution_space;
|
||||
typedef Kokkos::TeamPolicy<execution_space> Policy;
|
||||
typedef typename Policy::member_type team_type;
|
||||
typedef double value_type;
|
||||
|
||||
ViewType a;
|
||||
|
||||
VerifyTest(ViewType in):a(in) {}
|
||||
|
||||
KOKKOS_INLINE_FUNCTION
|
||||
void operator() (team_type team_member, double& value) const {
|
||||
unsigned int team_idx = team_member.league_rank() * team_member.team_size();
|
||||
|
||||
if((a.dimension_0()>team_idx+ team_member.team_rank()) &&
|
||||
(a.dimension(0)>team_idx+ team_member.team_rank())) {
|
||||
for( typename ExecutionSpace::size_type k=0;k<a.dimension_1();k++)
|
||||
for( typename ExecutionSpace::size_type l=0;l<a.dimension_2();l++)
|
||||
value += a(team_idx+ team_member.team_rank(),k,l);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
template<class ViewType , class ExecutionSpace>
|
||||
struct VerifyTest<ViewType , ExecutionSpace , 4> {
|
||||
typedef ExecutionSpace execution_space;
|
||||
typedef Kokkos::TeamPolicy<execution_space> Policy;
|
||||
typedef typename Policy::member_type team_type;
|
||||
typedef double value_type;
|
||||
|
||||
ViewType a;
|
||||
|
||||
VerifyTest(ViewType in):a(in) {}
|
||||
|
||||
KOKKOS_INLINE_FUNCTION
|
||||
void operator() (team_type team_member, double& value) const {
|
||||
unsigned int team_idx = team_member.league_rank() * team_member.team_size();
|
||||
|
||||
if((a.dimension_0()>team_idx+ team_member.team_rank()) &&
|
||||
(a.dimension(0)>team_idx+ team_member.team_rank())) {
|
||||
for( typename ExecutionSpace::size_type k=0;k<a.dimension_1();k++)
|
||||
for( typename ExecutionSpace::size_type l=0;l<a.dimension_2();l++)
|
||||
for( typename ExecutionSpace::size_type m=0;m<a.dimension_3();m++)
|
||||
value += a(team_idx+ team_member.team_rank(),k,l,m);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
template<class ViewType , class ExecutionSpace>
|
||||
struct VerifyTest<ViewType , ExecutionSpace , 5> {
|
||||
typedef ExecutionSpace execution_space;
|
||||
typedef Kokkos::TeamPolicy<execution_space> Policy;
|
||||
typedef typename Policy::member_type team_type;
|
||||
typedef double value_type;
|
||||
|
||||
ViewType a;
|
||||
|
||||
VerifyTest(ViewType in):a(in) {}
|
||||
|
||||
KOKKOS_INLINE_FUNCTION
|
||||
void operator() (team_type team_member, double& value) const {
|
||||
unsigned int team_idx = team_member.league_rank() * team_member.team_size();
|
||||
|
||||
if((a.dimension_0()>team_idx+ team_member.team_rank()) &&
|
||||
(a.dimension(0)>team_idx+ team_member.team_rank())) {
|
||||
for( typename ExecutionSpace::size_type k=0;k<a.dimension_1();k++)
|
||||
for( typename ExecutionSpace::size_type l=0;l<a.dimension_2();l++)
|
||||
for( typename ExecutionSpace::size_type m=0;m<a.dimension_3();m++)
|
||||
for( typename ExecutionSpace::size_type n=0;n<a.dimension_4();n++)
|
||||
value += a(team_idx+ team_member.team_rank(),k,l,m,n);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
template<class ViewType , class ExecutionSpace>
|
||||
struct VerifyTest<ViewType , ExecutionSpace , 6> {
|
||||
typedef ExecutionSpace execution_space;
|
||||
typedef Kokkos::TeamPolicy<execution_space> Policy;
|
||||
typedef typename Policy::member_type team_type;
|
||||
typedef double value_type;
|
||||
|
||||
ViewType a;
|
||||
|
||||
VerifyTest(ViewType in):a(in) {}
|
||||
|
||||
KOKKOS_INLINE_FUNCTION
|
||||
void operator() (team_type team_member, double& value) const {
|
||||
unsigned int team_idx = team_member.league_rank() * team_member.team_size();
|
||||
|
||||
if((a.dimension_0()>team_idx+ team_member.team_rank()) &&
|
||||
(a.dimension(0)>team_idx+ team_member.team_rank())) {
|
||||
for( typename ExecutionSpace::size_type k=0;k<a.dimension_1();k++)
|
||||
for( typename ExecutionSpace::size_type l=0;l<a.dimension_2();l++)
|
||||
for( typename ExecutionSpace::size_type m=0;m<a.dimension_3();m++)
|
||||
for( typename ExecutionSpace::size_type n=0;n<a.dimension_4();n++)
|
||||
for( typename ExecutionSpace::size_type o=0;o<a.dimension_5();o++)
|
||||
value += a(team_idx+ team_member.team_rank(),k,l,m,n,o);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
template<class ViewType , class ExecutionSpace>
|
||||
struct VerifyTest<ViewType , ExecutionSpace , 7> {
|
||||
typedef ExecutionSpace execution_space;
|
||||
typedef Kokkos::TeamPolicy<execution_space> Policy;
|
||||
typedef typename Policy::member_type team_type;
|
||||
typedef double value_type;
|
||||
|
||||
ViewType a;
|
||||
|
||||
VerifyTest(ViewType in):a(in) {}
|
||||
|
||||
KOKKOS_INLINE_FUNCTION
|
||||
void operator() (team_type team_member, double& value) const {
|
||||
unsigned int team_idx = team_member.league_rank() * team_member.team_size();
|
||||
|
||||
if((a.dimension_0()>team_idx+ team_member.team_rank()) &&
|
||||
(a.dimension(0)>team_idx+ team_member.team_rank())) {
|
||||
for( typename ExecutionSpace::size_type k=0;k<a.dimension_1();k++)
|
||||
for( typename ExecutionSpace::size_type l=0;l<a.dimension_2();l++)
|
||||
for( typename ExecutionSpace::size_type m=0;m<a.dimension_3();m++)
|
||||
for( typename ExecutionSpace::size_type n=0;n<a.dimension_4();n++)
|
||||
for( typename ExecutionSpace::size_type o=0;o<a.dimension_5();o++)
|
||||
for( typename ExecutionSpace::size_type p=0;p<a.dimension_6();p++)
|
||||
value += a(team_idx+ team_member.team_rank(),k,l,m,n,o,p);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
template<class ViewType , class ExecutionSpace>
|
||||
struct VerifyTest<ViewType , ExecutionSpace , 8> {
|
||||
typedef ExecutionSpace execution_space;
|
||||
typedef Kokkos::TeamPolicy<execution_space> Policy;
|
||||
typedef typename Policy::member_type team_type;
|
||||
typedef double value_type;
|
||||
|
||||
ViewType a;
|
||||
|
||||
VerifyTest(ViewType in):a(in) {}
|
||||
|
||||
KOKKOS_INLINE_FUNCTION
|
||||
void operator() (team_type team_member, double& value) const {
|
||||
unsigned int team_idx = team_member.league_rank() * team_member.team_size();
|
||||
|
||||
if((a.dimension_0()>team_idx+ team_member.team_rank()) &&
|
||||
(a.dimension(0)>team_idx+ team_member.team_rank())) {
|
||||
for( typename ExecutionSpace::size_type k=0;k<a.dimension_1();k++)
|
||||
for( typename ExecutionSpace::size_type l=0;l<a.dimension_2();l++)
|
||||
for( typename ExecutionSpace::size_type m=0;m<a.dimension_3();m++)
|
||||
for( typename ExecutionSpace::size_type n=0;n<a.dimension_4();n++)
|
||||
for( typename ExecutionSpace::size_type o=0;o<a.dimension_5();o++)
|
||||
for( typename ExecutionSpace::size_type p=0;p<a.dimension_6();p++)
|
||||
for( typename ExecutionSpace::size_type q=0;q<a.dimension_7();q++)
|
||||
value += a(team_idx+ team_member.team_rank(),k,l,m,n,o,p,q);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
template <typename Scalar, class ExecutionSpace>
|
||||
struct test_segmented_view
|
||||
{
|
||||
typedef test_segmented_view<Scalar,ExecutionSpace> self_type;
|
||||
|
||||
typedef Scalar scalar_type;
|
||||
typedef ExecutionSpace execution_space;
|
||||
typedef Kokkos::TeamPolicy<execution_space> Policy;
|
||||
|
||||
double result;
|
||||
double reference;
|
||||
|
||||
template <class ViewType>
|
||||
void run_me(ViewType a, int max_length){
|
||||
const int team_size = Policy::team_size_max( GrowTest<ViewType,execution_space>(a) );
|
||||
const int nteams = max_length/team_size;
|
||||
|
||||
reference = 0;
|
||||
result = 0;
|
||||
|
||||
Kokkos::parallel_reduce(Policy(nteams,team_size),GrowTest<ViewType,execution_space>(a),reference);
|
||||
Kokkos::fence();
|
||||
Kokkos::parallel_reduce(Policy(nteams,team_size),VerifyTest<ViewType,execution_space>(a),result);
|
||||
Kokkos::fence();
|
||||
}
|
||||
|
||||
|
||||
test_segmented_view(unsigned int size,int rank)
|
||||
{
|
||||
reference = 0;
|
||||
result = 0;
|
||||
|
||||
const int dim_1 = 7;
|
||||
const int dim_2 = 3;
|
||||
const int dim_3 = 2;
|
||||
const int dim_4 = 3;
|
||||
const int dim_5 = 2;
|
||||
const int dim_6 = 4;
|
||||
//const int dim_7 = 3;
|
||||
|
||||
if(rank==1) {
|
||||
typedef Kokkos::Experimental::SegmentedView<Scalar*,Kokkos::LayoutLeft,ExecutionSpace> rank1_view;
|
||||
run_me< rank1_view >(rank1_view("Rank1",128,size), size);
|
||||
}
|
||||
if(rank==2) {
|
||||
typedef Kokkos::Experimental::SegmentedView<Scalar**,Kokkos::LayoutLeft,ExecutionSpace> rank2_view;
|
||||
run_me< rank2_view >(rank2_view("Rank2",128,size,dim_1), size);
|
||||
}
|
||||
if(rank==3) {
|
||||
typedef Kokkos::Experimental::SegmentedView<Scalar*[7][3][2],Kokkos::LayoutRight,ExecutionSpace> rank3_view;
|
||||
run_me< rank3_view >(rank3_view("Rank3",128,size), size);
|
||||
}
|
||||
if(rank==4) {
|
||||
typedef Kokkos::Experimental::SegmentedView<Scalar****,Kokkos::LayoutRight,ExecutionSpace> rank4_view;
|
||||
run_me< rank4_view >(rank4_view("Rank4",128,size,dim_1,dim_2,dim_3), size);
|
||||
}
|
||||
if(rank==5) {
|
||||
typedef Kokkos::Experimental::SegmentedView<Scalar*[7][3][2][3],Kokkos::LayoutLeft,ExecutionSpace> rank5_view;
|
||||
run_me< rank5_view >(rank5_view("Rank5",128,size), size);
|
||||
}
|
||||
if(rank==6) {
|
||||
typedef Kokkos::Experimental::SegmentedView<Scalar*****[2],Kokkos::LayoutRight,ExecutionSpace> rank6_view;
|
||||
run_me< rank6_view >(rank6_view("Rank6",128,size,dim_1,dim_2,dim_3,dim_4), size);
|
||||
}
|
||||
if(rank==7) {
|
||||
typedef Kokkos::Experimental::SegmentedView<Scalar*******,Kokkos::LayoutLeft,ExecutionSpace> rank7_view;
|
||||
run_me< rank7_view >(rank7_view("Rank7",128,size,dim_1,dim_2,dim_3,dim_4,dim_5,dim_6), size);
|
||||
}
|
||||
if(rank==8) {
|
||||
typedef Kokkos::Experimental::SegmentedView<Scalar*****[2][4][3],Kokkos::LayoutLeft,ExecutionSpace> rank8_view;
|
||||
run_me< rank8_view >(rank8_view("Rank8",128,size,dim_1,dim_2,dim_3,dim_4), size);
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
} // namespace Impl
|
||||
|
||||
|
||||
|
||||
|
||||
template <typename Scalar, class ExecutionSpace>
|
||||
void test_segmented_view(unsigned int size)
|
||||
{
|
||||
{
|
||||
typedef Kokkos::Experimental::SegmentedView<Scalar*****[2][4][3],Kokkos::LayoutLeft,ExecutionSpace> view_type;
|
||||
view_type a("A",128,size,7,3,2,3);
|
||||
double reference;
|
||||
|
||||
Impl::GrowTest<view_type,ExecutionSpace> f(a);
|
||||
|
||||
const int team_size = Kokkos::TeamPolicy<ExecutionSpace>::team_size_max( f );
|
||||
const int nteams = (size+team_size-1)/team_size;
|
||||
|
||||
Kokkos::parallel_reduce(Kokkos::TeamPolicy<ExecutionSpace>(nteams,team_size),f,reference);
|
||||
|
||||
size_t real_size = ((size+127)/128)*128;
|
||||
|
||||
ASSERT_EQ(real_size,a.dimension_0());
|
||||
ASSERT_EQ(7,a.dimension_1());
|
||||
ASSERT_EQ(3,a.dimension_2());
|
||||
ASSERT_EQ(2,a.dimension_3());
|
||||
ASSERT_EQ(3,a.dimension_4());
|
||||
ASSERT_EQ(2,a.dimension_5());
|
||||
ASSERT_EQ(4,a.dimension_6());
|
||||
ASSERT_EQ(3,a.dimension_7());
|
||||
ASSERT_EQ(real_size,a.dimension(0));
|
||||
ASSERT_EQ(7,a.dimension(1));
|
||||
ASSERT_EQ(3,a.dimension(2));
|
||||
ASSERT_EQ(2,a.dimension(3));
|
||||
ASSERT_EQ(3,a.dimension(4));
|
||||
ASSERT_EQ(2,a.dimension(5));
|
||||
ASSERT_EQ(4,a.dimension(6));
|
||||
ASSERT_EQ(3,a.dimension(7));
|
||||
ASSERT_EQ(8,a.Rank);
|
||||
}
|
||||
{
|
||||
Impl::test_segmented_view<Scalar,ExecutionSpace> test(size,1);
|
||||
ASSERT_EQ(test.reference,test.result);
|
||||
}
|
||||
{
|
||||
Impl::test_segmented_view<Scalar,ExecutionSpace> test(size,2);
|
||||
ASSERT_EQ(test.reference,test.result);
|
||||
}
|
||||
{
|
||||
Impl::test_segmented_view<Scalar,ExecutionSpace> test(size,3);
|
||||
ASSERT_EQ(test.reference,test.result);
|
||||
}
|
||||
{
|
||||
Impl::test_segmented_view<Scalar,ExecutionSpace> test(size,4);
|
||||
ASSERT_EQ(test.reference,test.result);
|
||||
}
|
||||
{
|
||||
Impl::test_segmented_view<Scalar,ExecutionSpace> test(size,5);
|
||||
ASSERT_EQ(test.reference,test.result);
|
||||
}
|
||||
{
|
||||
Impl::test_segmented_view<Scalar,ExecutionSpace> test(size,6);
|
||||
ASSERT_EQ(test.reference,test.result);
|
||||
}
|
||||
{
|
||||
Impl::test_segmented_view<Scalar,ExecutionSpace> test(size,7);
|
||||
ASSERT_EQ(test.reference,test.result);
|
||||
}
|
||||
{
|
||||
Impl::test_segmented_view<Scalar,ExecutionSpace> test(size,8);
|
||||
ASSERT_EQ(test.reference,test.result);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
} // namespace Test
|
||||
|
||||
#else
|
||||
|
||||
template <typename Scalar, class ExecutionSpace>
|
||||
void test_segmented_view(unsigned int ) {}
|
||||
|
||||
#endif
|
||||
|
||||
#endif /* #ifndef KOKKOS_TEST_SEGMENTEDVIEW_HPP */
|
||||
|
||||
@ -58,7 +58,6 @@
|
||||
#include <TestStaticCrsGraph.hpp>
|
||||
#include <TestVector.hpp>
|
||||
#include <TestDualView.hpp>
|
||||
#include <TestSegmentedView.hpp>
|
||||
#include <TestDynamicView.hpp>
|
||||
#include <TestComplex.hpp>
|
||||
|
||||
@ -67,6 +66,9 @@
|
||||
#include <Kokkos_DynRankView.hpp>
|
||||
#include <TestDynViewAPI.hpp>
|
||||
|
||||
#include <Kokkos_ErrorReporter.hpp>
|
||||
#include <TestErrorReporter.hpp>
|
||||
|
||||
namespace Test {
|
||||
|
||||
class serial : public ::testing::Test {
|
||||
@ -135,11 +137,6 @@ TEST_F( serial, bitset )
|
||||
test_dualview_combinations<int,Kokkos::Serial>(size); \
|
||||
}
|
||||
|
||||
#define SERIAL_SEGMENTEDVIEW_TEST( size ) \
|
||||
TEST_F( serial, segmentedview_##size##x) { \
|
||||
test_segmented_view<double,Kokkos::Serial>(size); \
|
||||
}
|
||||
|
||||
SERIAL_INSERT_TEST(close, 100000, 90000, 100, 500, true)
|
||||
SERIAL_INSERT_TEST(far, 100000, 90000, 100, 500, false)
|
||||
SERIAL_FAILED_INSERT_TEST( 10000, 1000 )
|
||||
@ -148,7 +145,6 @@ SERIAL_DEEP_COPY( 10000, 1 )
|
||||
SERIAL_VECTOR_COMBINE_TEST( 10 )
|
||||
SERIAL_VECTOR_COMBINE_TEST( 3057 )
|
||||
SERIAL_DUALVIEW_COMBINE_TEST( 10 )
|
||||
SERIAL_SEGMENTEDVIEW_TEST( 10000 )
|
||||
|
||||
#undef SERIAL_INSERT_TEST
|
||||
#undef SERIAL_FAILED_INSERT_TEST
|
||||
@ -156,7 +152,6 @@ SERIAL_SEGMENTEDVIEW_TEST( 10000 )
|
||||
#undef SERIAL_DEEP_COPY
|
||||
#undef SERIAL_VECTOR_COMBINE_TEST
|
||||
#undef SERIAL_DUALVIEW_COMBINE_TEST
|
||||
#undef SERIAL_SEGMENTEDVIEW_TEST
|
||||
|
||||
TEST_F( serial , dynamic_view )
|
||||
{
|
||||
@ -168,6 +163,19 @@ TEST_F( serial , dynamic_view )
|
||||
}
|
||||
}
|
||||
|
||||
#if defined(KOKKOS_CLASS_LAMBDA)
|
||||
TEST_F(serial, ErrorReporterViaLambda)
|
||||
{
|
||||
TestErrorReporter<ErrorReporterDriverUseLambda<Kokkos::Serial>>();
|
||||
}
|
||||
#endif
|
||||
|
||||
TEST_F(serial, ErrorReporter)
|
||||
{
|
||||
TestErrorReporter<ErrorReporterDriver<Kokkos::Serial>>();
|
||||
}
|
||||
|
||||
|
||||
} // namespace Test
|
||||
|
||||
#endif // KOKKOS_HAVE_SERIAL
|
||||
|
||||
@ -62,11 +62,13 @@
|
||||
#include <TestVector.hpp>
|
||||
#include <TestDualView.hpp>
|
||||
#include <TestDynamicView.hpp>
|
||||
#include <TestSegmentedView.hpp>
|
||||
|
||||
#include <Kokkos_DynRankView.hpp>
|
||||
#include <TestDynViewAPI.hpp>
|
||||
|
||||
#include <Kokkos_ErrorReporter.hpp>
|
||||
#include <TestErrorReporter.hpp>
|
||||
|
||||
namespace Test {
|
||||
|
||||
class threads : public ::testing::Test {
|
||||
@ -145,12 +147,6 @@ TEST_F( threads , staticcrsgraph )
|
||||
test_dualview_combinations<int,Kokkos::Threads>(size); \
|
||||
}
|
||||
|
||||
#define THREADS_SEGMENTEDVIEW_TEST( size ) \
|
||||
TEST_F( threads, segmentedview_##size##x) { \
|
||||
test_segmented_view<double,Kokkos::Threads>(size); \
|
||||
}
|
||||
|
||||
|
||||
THREADS_INSERT_TEST(far, 100000, 90000, 100, 500, false)
|
||||
THREADS_FAILED_INSERT_TEST( 10000, 1000 )
|
||||
THREADS_DEEP_COPY( 10000, 1 )
|
||||
@ -158,7 +154,6 @@ THREADS_DEEP_COPY( 10000, 1 )
|
||||
THREADS_VECTOR_COMBINE_TEST( 10 )
|
||||
THREADS_VECTOR_COMBINE_TEST( 3057 )
|
||||
THREADS_DUALVIEW_COMBINE_TEST( 10 )
|
||||
THREADS_SEGMENTEDVIEW_TEST( 10000 )
|
||||
|
||||
|
||||
#undef THREADS_INSERT_TEST
|
||||
@ -167,8 +162,6 @@ THREADS_SEGMENTEDVIEW_TEST( 10000 )
|
||||
#undef THREADS_DEEP_COPY
|
||||
#undef THREADS_VECTOR_COMBINE_TEST
|
||||
#undef THREADS_DUALVIEW_COMBINE_TEST
|
||||
#undef THREADS_SEGMENTEDVIEW_TEST
|
||||
|
||||
|
||||
|
||||
TEST_F( threads , dynamic_view )
|
||||
@ -181,6 +174,19 @@ TEST_F( threads , dynamic_view )
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#if defined(KOKKOS_CLASS_LAMBDA)
|
||||
TEST_F(threads, ErrorReporterViaLambda)
|
||||
{
|
||||
TestErrorReporter<ErrorReporterDriverUseLambda<Kokkos::Threads>>();
|
||||
}
|
||||
#endif
|
||||
|
||||
TEST_F(threads, ErrorReporter)
|
||||
{
|
||||
TestErrorReporter<ErrorReporterDriver<Kokkos::Threads>>();
|
||||
}
|
||||
|
||||
} // namespace Test
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user