Skip to content

Commit

Permalink
Merge pull request #32 from sslattery/add_experimental
Browse files Browse the repository at this point in the history
Experimental Namespace
  • Loading branch information
sslattery authored Oct 12, 2018
2 parents 90b1af9 + e95b8b4 commit 993f839
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 16 deletions.
3 changes: 3 additions & 0 deletions core/src/Cabana_ExecutionPolicy.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@

namespace Cabana
{
namespace Experimental
{
//---------------------------------------------------------------------------//
/*!
\class RangePolicy
Expand Down Expand Up @@ -57,6 +59,7 @@ class RangePolicy

//---------------------------------------------------------------------------//

} // end namespace Experimental
} // end namespace Cabana

#endif // end CABANA_EXECUTIONPOLICY_HPP
4 changes: 4 additions & 0 deletions core/src/Cabana_NeighborList.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ class NeighborList
const int neighbor_index );
};

namespace Experimental
{
//---------------------------------------------------------------------------//
// Neighbor Parallel For
//---------------------------------------------------------------------------//
Expand Down Expand Up @@ -244,6 +246,8 @@ inline void neighbor_parallel_for( const ExecutionPolicy& exec_policy,

//---------------------------------------------------------------------------//

} // end namespace Experimental

} // end namespace Cabana

#endif // end CABANA_NEIGHBORLIST_HPP
3 changes: 3 additions & 0 deletions core/src/Cabana_Parallel.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,8 @@ getArrayBounds( const int begin,

} // end namespace impl

namespace Experimental
{
//---------------------------------------------------------------------------//
// Algorithm tags.

Expand Down Expand Up @@ -378,6 +380,7 @@ inline void parallel_for( const ExecutionPolicy& exec_policy,

//---------------------------------------------------------------------------//

} // end namespace Experimental
} // end namespace Cabana

#endif // end CABANA_PARALLEL_HPP
8 changes: 4 additions & 4 deletions core/src/impl/Cabana_PerformanceTraits.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class PerformanceTraits<Kokkos::Serial>
{
public:
static constexpr int vector_length = 16;
using parallel_for_tag = StructParallelTag;
using parallel_for_tag = Experimental::StructParallelTag;
};
#endif

Expand All @@ -49,7 +49,7 @@ class PerformanceTraits<Kokkos::Threads>
{
public:
static constexpr int vector_length = 16;
using parallel_for_tag = StructParallelTag;
using parallel_for_tag = Experimental::StructParallelTag;
};
#endif

Expand All @@ -61,7 +61,7 @@ class PerformanceTraits<Kokkos::OpenMP>
{
public:
static constexpr int vector_length = 16;
using parallel_for_tag = StructParallelTag;
using parallel_for_tag = Experimental::StructParallelTag;
};
#endif

Expand All @@ -73,7 +73,7 @@ class PerformanceTraits<Kokkos::Cuda>
{
public:
static constexpr int vector_length = Kokkos::Impl::CudaTraits::WarpSize;
using parallel_for_tag = IndexParallelTag;
using parallel_for_tag = Experimental::IndexParallelTag;
};
#endif

Expand Down
10 changes: 5 additions & 5 deletions core/unit_test/tstNeighborList.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -383,11 +383,11 @@ void testNeighborParallelFor()
{ Kokkos::atomic_add( &serial_result(i), n ); };
auto team_count_op = KOKKOS_LAMBDA( const int i, const int n )
{ Kokkos::atomic_add( &team_result(i), n ); };
Cabana::RangePolicy<aosoa_t::vector_length,TEST_EXECSPACE> policy( aosoa );
Cabana::neighbor_parallel_for(
policy, serial_count_op, nlist, Cabana::SerialNeighborOpTag() );
Cabana::neighbor_parallel_for(
policy, team_count_op, nlist, Cabana::TeamNeighborOpTag() );
Cabana::Experimental::RangePolicy<aosoa_t::vector_length,TEST_EXECSPACE> policy( aosoa );
Cabana::Experimental::neighbor_parallel_for(
policy, serial_count_op, nlist, Cabana::Experimental::SerialNeighborOpTag() );
Cabana::Experimental::neighbor_parallel_for(
policy, team_count_op, nlist, Cabana::Experimental::TeamNeighborOpTag() );

// Get the expected result in serial
for ( int p = 0; p < num_particle; ++p )
Expand Down
17 changes: 10 additions & 7 deletions core/unit_test/tstParallel.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ void runTest()
AoSoA_t aosoa( num_data );

// Create an execution policy using the begin and end of the AoSoA.
Cabana::RangePolicy<AoSoA_t::vector_length,TEST_EXECSPACE>
Cabana::Experimental::RangePolicy<AoSoA_t::vector_length,TEST_EXECSPACE>
range_policy( 0, aosoa.size() );

// Create a functor to operate on.
Expand All @@ -158,7 +158,8 @@ void runTest()
OpType func_1( aosoa, fval, dval, ival );

// Loop in parallel using 1D struct parallelism.
Cabana::parallel_for( range_policy, func_1, Cabana::StructParallelTag() );
Cabana::Experimental::parallel_for(
range_policy, func_1, Cabana::Experimental::StructParallelTag() );

// Check data members for proper initialization.
checkDataMembers( aosoa, fval, dval, ival, dim_1, dim_2, dim_3 );
Expand All @@ -170,7 +171,8 @@ void runTest()
OpType func_2( aosoa, fval, dval, ival );

// Loop in parallel using 1D array parallelism.
Cabana::parallel_for( range_policy, func_2, Cabana::ArrayParallelTag() );
Cabana::Experimental::parallel_for(
range_policy, func_2, Cabana::Experimental::ArrayParallelTag() );

// Check data members for proper initialization.
checkDataMembers( aosoa, fval, dval, ival, dim_1, dim_2, dim_3 );
Expand All @@ -182,17 +184,18 @@ void runTest()
OpType func_3( aosoa, fval, dval, ival );

// Loop in parallel using 2D struct and array parallelism.
Cabana::parallel_for(
range_policy, func_3, Cabana::StructAndArrayParallelTag() );
Cabana::Experimental::parallel_for(
range_policy, func_3, Cabana::Experimental::StructAndArrayParallelTag() );

// Check data members for proper initialization.
checkDataMembers( aosoa, fval, dval, ival, dim_1, dim_2, dim_3 );

// Do one more loop but this time auto-dispatch. Reuse the first functor
// but this time create an execution policy that automatically grabs begin
// and end from the aosoa.
Cabana::RangePolicy<AoSoA_t::vector_length,TEST_EXECSPACE> aosoa_policy( aosoa );
Cabana::parallel_for( aosoa_policy, func_1 );
Cabana::Experimental::RangePolicy<AoSoA_t::vector_length,TEST_EXECSPACE>
aosoa_policy( aosoa );
Cabana::Experimental::parallel_for( aosoa_policy, func_1 );

// Check data members for proper initialization.
fval = 3.4;
Expand Down

0 comments on commit 993f839

Please sign in to comment.