Skip to content

Commit

Permalink
fixup: remove outdated Kokkos math namespace in test
Browse files Browse the repository at this point in the history
  • Loading branch information
streeve committed Feb 9, 2024
1 parent 83eb558 commit 09f172a
Showing 1 changed file with 29 additions and 31 deletions.
60 changes: 29 additions & 31 deletions grid/unit_test/tstBovWriter.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,12 +71,6 @@ void writeTest3d()
createArray<double, TEST_MEMSPACE>( "cell_field_3d", cell_layout );
auto cell_data = cell_field->view();

// FIXME_SYCL (remove ifdef when newest Kokkos is required)
#if ( defined __SYCL_DEVICE_ONLY__ )
using Kokkos::Experimental::cos;
using Kokkos::Experimental::fabs;
#endif

Kokkos::parallel_for(
"fill_cell_field",
createExecutionPolicy(
Expand All @@ -87,8 +81,9 @@ void writeTest3d()
double yarg = double( off_j + j ) / num_cell_dev[1];
double zarg = double( off_k + k ) / num_cell_dev[2];
cell_data( i, j, k, 0 ) =
1.0 + fabs( cos( pi2 * xarg ) * cos( pi2 * yarg ) *
cos( pi2 * zarg ) );
1.0 + fabs( Kokkos::cos( pi2 * xarg ) *
Kokkos::cos( pi2 * yarg ) *
Kokkos::cos( pi2 * zarg ) );
} );

// Create a vector node field and fill it with data.
Expand All @@ -105,9 +100,12 @@ void writeTest3d()
double xarg = double( off_i + i ) / num_cell_dev[0];
double yarg = double( off_j + j ) / num_cell_dev[1];
double zarg = double( off_k + k ) / num_cell_dev[2];
node_data( i, j, k, Dim::I ) = 1.0 + fabs( cos( pi2 * xarg ) );
node_data( i, j, k, Dim::J ) = 1.0 + fabs( cos( pi2 * yarg ) );
node_data( i, j, k, Dim::K ) = 1.0 + fabs( cos( pi2 * zarg ) );
node_data( i, j, k, Dim::I ) =
1.0 + fabs( Kokkos::cos( pi2 * xarg ) );
node_data( i, j, k, Dim::J ) =
1.0 + fabs( Kokkos::cos( pi2 * yarg ) );
node_data( i, j, k, Dim::K ) =
1.0 + fabs( Kokkos::cos( pi2 * zarg ) );
} );

// Gather the node data.
Expand Down Expand Up @@ -145,10 +143,10 @@ void writeTest3d()
cell_data_file.seekg( cell_id * sizeof( double ) );
cell_data_file.read( (char*)&cell_value, sizeof( double ) );

EXPECT_FLOAT_EQ(
cell_value,
1.0 + fabs( cos( pi2 * xarg ) * cos( pi2 * yarg ) *
cos( pi2 * zarg ) ) );
EXPECT_FLOAT_EQ( cell_value,
1.0 + fabs( Kokkos::cos( pi2 * xarg ) *
Kokkos::cos( pi2 * yarg ) *
Kokkos::cos( pi2 * zarg ) ) );
++cell_id;
}

Expand Down Expand Up @@ -178,19 +176,19 @@ void writeTest3d()
node_data_file.seekg( node_id * sizeof( double ) );
node_data_file.read( (char*)&node_value, sizeof( double ) );
EXPECT_FLOAT_EQ( node_value,
1.0 + fabs( cos( pi2 * xarg ) ) );
1.0 + fabs( Kokkos::cos( pi2 * xarg ) ) );
++node_id;

node_data_file.seekg( node_id * sizeof( double ) );
node_data_file.read( (char*)&node_value, sizeof( double ) );
EXPECT_FLOAT_EQ( node_value,
1.0 + fabs( cos( pi2 * yarg ) ) );
1.0 + fabs( Kokkos::cos( pi2 * yarg ) ) );
++node_id;

node_data_file.seekg( node_id * sizeof( double ) );
node_data_file.read( (char*)&node_value, sizeof( double ) );
EXPECT_FLOAT_EQ( node_value,
1.0 + fabs( cos( pi2 * zarg ) ) );
1.0 + fabs( Kokkos::cos( pi2 * zarg ) ) );
++node_id;
}

Expand Down Expand Up @@ -236,11 +234,6 @@ void writeTest2d()
createArray<double, TEST_MEMSPACE>( "cell_field_2d", cell_layout );
auto cell_data = cell_field->view();

// FIXME_SYCL (remove ifdef when newest Kokkos is required)
#if ( defined __SYCL_DEVICE_ONLY__ )
using Kokkos::Experimental::cos;
using Kokkos::Experimental::fabs;
#endif
Kokkos::parallel_for(
"fill_cell_field",
createExecutionPolicy(
Expand All @@ -249,8 +242,8 @@ void writeTest2d()
KOKKOS_LAMBDA( const int i, const int j ) {
double xarg = double( off_i + i ) / num_cell_dev[0];
double yarg = double( off_j + j ) / num_cell_dev[1];
cell_data( i, j, 0 ) =
1.0 + fabs( cos( pi2 * xarg ) * cos( pi2 * yarg ) );
cell_data( i, j, 0 ) = 1.0 + fabs( Kokkos::cos( pi2 * xarg ) *
Kokkos::cos( pi2 * yarg ) );
} );

// Create a vector node field and fill it with data.
Expand All @@ -266,8 +259,10 @@ void writeTest2d()
KOKKOS_LAMBDA( const int i, const int j ) {
double xarg = double( off_i + i ) / num_cell_dev[0];
double yarg = double( off_j + j ) / num_cell_dev[1];
node_data( i, j, Dim::I ) = 1.0 + fabs( cos( pi2 * xarg ) );
node_data( i, j, Dim::J ) = 1.0 + fabs( cos( pi2 * yarg ) );
node_data( i, j, Dim::I ) =
1.0 + fabs( Kokkos::cos( pi2 * xarg ) );
node_data( i, j, Dim::J ) =
1.0 + fabs( Kokkos::cos( pi2 * yarg ) );
} );

// Gather the node data.
Expand Down Expand Up @@ -302,8 +297,9 @@ void writeTest2d()
cell_data_file.seekg( cell_id * sizeof( double ) );
cell_data_file.read( (char*)&cell_value, sizeof( double ) );

EXPECT_FLOAT_EQ( cell_value, 1.0 + fabs( cos( pi2 * xarg ) *
cos( pi2 * yarg ) ) );
EXPECT_FLOAT_EQ( cell_value,
1.0 + fabs( Kokkos::cos( pi2 * xarg ) *
Kokkos::cos( pi2 * yarg ) ) );
++cell_id;
}

Expand All @@ -328,12 +324,14 @@ void writeTest2d()

node_data_file.seekg( node_id * sizeof( double ) );
node_data_file.read( (char*)&node_value, sizeof( double ) );
EXPECT_FLOAT_EQ( node_value, 1.0 + fabs( cos( pi2 * xarg ) ) );
EXPECT_FLOAT_EQ( node_value,
1.0 + fabs( Kokkos::cos( pi2 * xarg ) ) );
++node_id;

node_data_file.seekg( node_id * sizeof( double ) );
node_data_file.read( (char*)&node_value, sizeof( double ) );
EXPECT_FLOAT_EQ( node_value, 1.0 + fabs( cos( pi2 * yarg ) ) );
EXPECT_FLOAT_EQ( node_value,
1.0 + fabs( Kokkos::cos( pi2 * yarg ) ) );
++node_id;
}

Expand Down

0 comments on commit 09f172a

Please sign in to comment.