Skip to content

Commit

Permalink
changes for generic kernel functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
rrsettgast committed May 23, 2024
1 parent 43ca28e commit 50aabbc
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 35 deletions.
22 changes: 11 additions & 11 deletions src/common/unitTests/testIndexTypes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,22 +22,23 @@ using namespace shiva;

void testLinearIndexTypeHelper()
{
int * data = nullptr;
pmpl::genericKernelWrapper( 10, data, [] SHIVA_HOST_DEVICE ( int * const kdata )
const int N = 10;
int * data = new int[N];

pmpl::genericKernelWrapper( N, data, [] SHIVA_HOST_DEVICE ( int * const kdata )
{
int i = 0;
LinearIndex< int > a = 0;
for ( a = 0, i = 0; a < 10; ++a, ++i )
for ( a = 0, i = 0; a < N; ++a, ++i )
{
kdata[i] = linearIndex( a );
}
} );
for ( int i = 0; i < 10; ++i )
for ( int i = 0; i < N; ++i )
{
EXPECT_EQ( data[i], i );
}
pmpl::deallocateData( data );

delete[] data;
}

TEST( testIndexTypes, testLinearIndexType )
Expand All @@ -49,7 +50,7 @@ TEST( testIndexTypes, testLinearIndexType )

void testMultiIndexManualLoopHelper()
{
int * data = nullptr;
int * data = new int[8];
pmpl::genericKernelWrapper( 8, data, [] SHIVA_HOST_DEVICE ( int * const kdata )
{
MultiIndexRange< int, 2, 2, 2 > index{ { 1, 0, 0 } };
Expand Down Expand Up @@ -79,7 +80,7 @@ void testMultiIndexManualLoopHelper()
}
}
}
pmpl::deallocateData( data );
delete[] data;
}
TEST( testIndexTypes, testMultiIndexManualLoop )
{
Expand All @@ -89,7 +90,7 @@ TEST( testIndexTypes, testMultiIndexManualLoop )

void testMultiIndexForRangeHelper()
{
int * data = nullptr;
int * data = new int[8];
pmpl::genericKernelWrapper( 8, data, [] SHIVA_HOST_DEVICE ( int * const kdata )
{
MultiIndexRange< int, 2, 2, 2 > index{ { 0, 0, 0 } };
Expand All @@ -110,8 +111,7 @@ void testMultiIndexForRangeHelper()
}
}
}
pmpl::deallocateData( data );

delete[] data;
}
TEST( testIndexTypes, testMultiIndexForRange )
{
Expand Down
20 changes: 10 additions & 10 deletions src/geometry/mapping/unitTests/testLinearTransform.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ SHIVA_HOST_DEVICE auto makeLinearTransform( REAL_TYPE const (&X)[8][3] )

void testConstructionAndSettersHelper()
{
double * data = nullptr;
double * data = new double[8 * 3];
pmpl::genericKernelWrapper( 8 * 3, data, [] SHIVA_DEVICE ( double * const kernelData )
{
auto const cell = makeLinearTransform( Xref );
Expand Down Expand Up @@ -166,7 +166,7 @@ void testConstructionAndSettersHelper()
}
}
}
pmpl::deallocateData( data );
delete[] data;
}
TEST( testLinearTransform, testConstructionAndSetters )
{
Expand All @@ -176,7 +176,7 @@ TEST( testLinearTransform, testConstructionAndSetters )

void testJacobianFunctionModifyLvalueRefArgHelper()
{
double * data = nullptr;
double * data = new double[9 * 8];
pmpl::genericKernelWrapper( 9 * 8, data, [] SHIVA_DEVICE ( double * const kernelData )
{
auto cell = makeLinearTransform( Xref );
Expand Down Expand Up @@ -205,7 +205,7 @@ void testJacobianFunctionModifyLvalueRefArgHelper()
}
}
}
pmpl::deallocateData( data );
delete[] data;
}

TEST( testLinearTransform, testJacobianFunctionModifyLvalueRefArg )
Expand All @@ -216,7 +216,7 @@ TEST( testLinearTransform, testJacobianFunctionModifyLvalueRefArg )

void testJacobianFunctionReturnByValueHelper()
{
double * data = nullptr;
double * data = new double[9 * 8];
pmpl::genericKernelWrapper( 9 * 8, data, [] SHIVA_DEVICE ( double * const kernelData )
{
auto cell = makeLinearTransform( Xref );
Expand All @@ -243,7 +243,7 @@ void testJacobianFunctionReturnByValueHelper()
}
}
}
pmpl::deallocateData( data );
delete[] data;
}

TEST( testLinearTransform, testJacobianFunctionReturnByValue )
Expand All @@ -254,7 +254,7 @@ TEST( testLinearTransform, testJacobianFunctionReturnByValue )

void testInvJacobianFunctionModifyLvalueRefArgHelper()
{
double * data = nullptr;
double * data = new double[10 * 8];
pmpl::genericKernelWrapper( 10 * 8, data, [] SHIVA_DEVICE ( double * const kernelData )
{
auto cell = makeLinearTransform( Xref );
Expand Down Expand Up @@ -287,7 +287,7 @@ void testInvJacobianFunctionModifyLvalueRefArgHelper()
}
}
}
pmpl::deallocateData( data );
delete[] data;

}

Expand All @@ -299,7 +299,7 @@ TEST( testLinearTransform, testInvJacobianFunctionModifyLvalueRefArg )

void testInvJacobianFunctionReturnByValueHelper()
{
double * data = nullptr;
double * data = new double[10 * 8];
pmpl::genericKernelWrapper( 10 * 8, data, [] SHIVA_DEVICE ( double * const kernelData )
{
auto cell = makeLinearTransform( Xref );
Expand Down Expand Up @@ -329,7 +329,7 @@ void testInvJacobianFunctionReturnByValueHelper()
}
}
}
pmpl::deallocateData( data );
delete[] data;
}

TEST( testLinearTransform, testInvJacobianFunctionReturnByValue )
Expand Down
20 changes: 10 additions & 10 deletions src/geometry/mapping/unitTests/testScaling.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ SHIVA_CONSTEXPR_HOSTDEVICE_FORCEINLINE auto makeScaling( REAL_TYPE const (&h)[3]
void testConstructionAndSettersHelper()
{
constexpr double h[3] = { 10, 20, 30 };
double * data = nullptr;
double * data = new double[3];
pmpl::genericKernelWrapper( 3, data, [ = ] SHIVA_HOST_DEVICE ( double * const kdata )
{
auto cell = makeScaling( h );
Expand All @@ -49,7 +49,7 @@ void testConstructionAndSettersHelper()
EXPECT_EQ( data[1], h[1] );
EXPECT_EQ( data[2], h[2] );

pmpl::deallocateData( data );
delete[] data;
}
TEST( testScaling, testConstructionAndSetters )
{
Expand All @@ -60,7 +60,7 @@ TEST( testScaling, testConstructionAndSetters )
void testJacobianFunctionModifyLvalueRefArgHelper()
{
constexpr double h[3] = { 10, 20, 30 };
double * data = nullptr;
double * data = new double[3];
pmpl::genericKernelWrapper( 3, data, [ = ] SHIVA_HOST_DEVICE ( double * const kdata )
{
auto cell = makeScaling( h );
Expand All @@ -75,7 +75,7 @@ void testJacobianFunctionModifyLvalueRefArgHelper()
EXPECT_EQ( data[1], ( h[1] / 2 ) );
EXPECT_EQ( data[2], ( h[2] / 2 ) );

pmpl::deallocateData( data );
delete[] data;
}

TEST( testScaling, testJacobianFunctionModifyLvalueRefArg )
Expand All @@ -86,7 +86,7 @@ TEST( testScaling, testJacobianFunctionModifyLvalueRefArg )
void testJacobianFunctionReturnByValueHelper()
{
constexpr double h[3] = { 10, 20, 30 };
double * data = nullptr;
double * data = new double[3];
pmpl::genericKernelWrapper( 3, data, [ = ] SHIVA_HOST_DEVICE ( double * const kdata )
{
auto cell = makeScaling( h );
Expand All @@ -100,7 +100,7 @@ void testJacobianFunctionReturnByValueHelper()
EXPECT_EQ( data[1], ( h[1] / 2 ) );
EXPECT_EQ( data[2], ( h[2] / 2 ) );

pmpl::deallocateData( data );
delete[] data;
}
TEST( testScaling, testJacobianFunctionReturnByValue )
{
Expand All @@ -110,7 +110,7 @@ TEST( testScaling, testJacobianFunctionReturnByValue )
void testInvJacobianFunctionModifyLvalueRefArgHelper()
{
constexpr double h[3] = { 10, 20, 30 };
double * data = nullptr;
double * data = new double[4];
pmpl::genericKernelWrapper( 4, data, [ = ] SHIVA_HOST_DEVICE ( double * const kdata )
{
auto cell = makeScaling( h );
Expand All @@ -128,7 +128,7 @@ void testInvJacobianFunctionModifyLvalueRefArgHelper()
EXPECT_EQ( data[2], ( 2 / h[1] ) );
EXPECT_EQ( data[3], ( 2 / h[2] ) );

pmpl::deallocateData( data );
delete[] data;
}
TEST( testScaling, testInvJacobianFunctionModifyLvalueRefArg )
{
Expand All @@ -138,7 +138,7 @@ TEST( testScaling, testInvJacobianFunctionModifyLvalueRefArg )
void testInvJacobianFunctionReturnByValueHelper()
{
constexpr double h[3] = { 10, 20, 30 };
double * data = nullptr;
double * data = new double[4];
pmpl::genericKernelWrapper( 4, data, [ = ] SHIVA_HOST_DEVICE ( double * const kdata )
{
auto cell = makeScaling( h );
Expand All @@ -154,7 +154,7 @@ void testInvJacobianFunctionReturnByValueHelper()
EXPECT_EQ( data[2], ( 2 / h[1] ) );
EXPECT_EQ( data[3], ( 2 / h[2] ) );

pmpl::deallocateData( data );
delete[] data;
}
TEST( testScaling, testInvJacobianFunctionReturnByValue )
{
Expand Down
8 changes: 4 additions & 4 deletions src/geometry/mapping/unitTests/testUniformScaling.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,14 @@ SHIVA_CONSTEXPR_HOSTDEVICE_FORCEINLINE auto makeUniformScaling( REAL_TYPE const
void testConstructionAndSettersHelper()
{
constexpr double h = 3.14;
double * data = nullptr;
double * data = new double[1];
pmpl::genericKernelWrapper( 1, data, [] SHIVA_HOST_DEVICE ( double * const kdata )
{
auto cell = makeUniformScaling( h );
kdata[0] = cell.getData();
} );
EXPECT_EQ( data[0], h );
pmpl::deallocateData( data );
delete[] data;
}

TEST( testUniformScaling, testConstructionAndSetters )
Expand All @@ -56,7 +56,7 @@ TEST( testUniformScaling, testConstructionAndSetters )
void testJacobianFunctionModifyLvalueRefArgHelper()
{
constexpr double h = 3.14;
double * data = nullptr;
double * data = new double[1];
pmpl::genericKernelWrapper( 1, data, [] SHIVA_HOST_DEVICE ( double * const kdata )
{
auto cell = makeUniformScaling( h );
Expand All @@ -65,7 +65,7 @@ void testJacobianFunctionModifyLvalueRefArgHelper()
kdata[0] = J( 0 );
} );
EXPECT_EQ( data[0], ( h / 2 ) );
pmpl::deallocateData( data );
delete[] data;
}
TEST( testUniformScaling, testJacobianFunctionModifyLvalueRefArg )
{
Expand Down

0 comments on commit 50aabbc

Please sign in to comment.