Skip to content
Snippets Groups Projects
Commit 453f554c authored by Tomáš Oberhuber's avatar Tomáš Oberhuber Committed by Tomáš Oberhuber
Browse files

Changed File load and save from bool to void.

parent 1cd1f997
No related branches found
No related tags found
1 merge request!29Revision
...@@ -160,22 +160,14 @@ inline void StaticArray< Size, Value >::setValue( const ValueType& val ) ...@@ -160,22 +160,14 @@ inline void StaticArray< Size, Value >::setValue( const ValueType& val )
template< int Size, typename Value > template< int Size, typename Value >
bool StaticArray< Size, Value >::save( File& file ) const bool StaticArray< Size, Value >::save( File& file ) const
{ {
if( ! file.save< Value, Value, Devices::Host >( data, size ) ) file.save< Value, Value, Devices::Host >( data, size );
{
std::cerr << "Unable to write " << getType() << "." << std::endl;
return false;
}
return true; return true;
} }
template< int Size, typename Value > template< int Size, typename Value >
bool StaticArray< Size, Value >::load( File& file) bool StaticArray< Size, Value >::load( File& file)
{ {
if( ! file.load< Value, Value, Devices::Host >( data, size ) ) file.load< Value, Value, Devices::Host >( data, size );
{
std::cerr << "Unable to read " << getType() << "." << std::endl;
return false;
}
return true; return true;
} }
......
...@@ -29,18 +29,18 @@ TEST( FileTest, WriteAndRead ) ...@@ -29,18 +29,18 @@ TEST( FileTest, WriteAndRead )
int intData( 5 ); int intData( 5 );
double doubleData[ 3 ] = { 1.0, 2.0, 3.0 }; double doubleData[ 3 ] = { 1.0, 2.0, 3.0 };
const double constDoubleData = 3.14; const double constDoubleData = 3.14;
ASSERT_TRUE( file.save( &intData ) ); file.save( &intData );
ASSERT_TRUE( file.save( doubleData, 3 ) ); file.save( doubleData, 3 );
ASSERT_TRUE( file.save( &constDoubleData ) ); file.save( &constDoubleData );
file.close(); file.close();
file.open( String( "test-file.tnl" ), File::Mode::In ); file.open( String( "test-file.tnl" ), File::Mode::In );
int newIntData; int newIntData;
double newDoubleData[ 3 ]; double newDoubleData[ 3 ];
double newConstDoubleData; double newConstDoubleData;
ASSERT_TRUE( file.load( &newIntData, 1 ) ); file.load( &newIntData, 1 );
ASSERT_TRUE( file.load( newDoubleData, 3 ) ); file.load( newDoubleData, 3 );
ASSERT_TRUE( file.load( &newConstDoubleData, 1 ) ); file.load( &newConstDoubleData, 1 );
EXPECT_EQ( newIntData, intData ); EXPECT_EQ( newIntData, intData );
for( int i = 0; i < 3; i ++ ) for( int i = 0; i < 3; i ++ )
...@@ -110,12 +110,9 @@ TEST( FileTest, WriteAndReadCUDA ) ...@@ -110,12 +110,9 @@ TEST( FileTest, WriteAndReadCUDA )
File file; File file;
file.open( String( "test-file.tnl" ), File::Mode::Out ); file.open( String( "test-file.tnl" ), File::Mode::Out );
bool status = file.save< int, int, Devices::Cuda >( cudaIntData ); file.save< int, int, Devices::Cuda >( cudaIntData );
ASSERT_TRUE( status ); file.save< float, float, Devices::Cuda >( cudaFloatData, 3 );
status = file.save< float, float, Devices::Cuda >( cudaFloatData, 3 ); file.save< const double, double, Devices::Cuda >( cudaConstDoubleData );
ASSERT_TRUE( status );
status = file.save< const double, double, Devices::Cuda >( cudaConstDoubleData );
ASSERT_TRUE( status );
file.close(); file.close();
file.open( String( "test-file.tnl" ), File::Mode::In ); file.open( String( "test-file.tnl" ), File::Mode::In );
...@@ -128,12 +125,9 @@ TEST( FileTest, WriteAndReadCUDA ) ...@@ -128,12 +125,9 @@ TEST( FileTest, WriteAndReadCUDA )
cudaMalloc( ( void** ) &newCudaIntData, sizeof( int ) ); cudaMalloc( ( void** ) &newCudaIntData, sizeof( int ) );
cudaMalloc( ( void** ) &newCudaFloatData, 3 * sizeof( float ) ); cudaMalloc( ( void** ) &newCudaFloatData, 3 * sizeof( float ) );
cudaMalloc( ( void** ) &newCudaDoubleData, sizeof( double ) ); cudaMalloc( ( void** ) &newCudaDoubleData, sizeof( double ) );
status = file.load< int, int, Devices::Cuda >( newCudaIntData, 1 ); file.load< int, int, Devices::Cuda >( newCudaIntData, 1 );
ASSERT_TRUE( status ); file.load< float, float, Devices::Cuda >( newCudaFloatData, 3 );
status = file.load< float, float, Devices::Cuda >( newCudaFloatData, 3 ); file.load< double, double, Devices::Cuda >( newCudaDoubleData, 1 );
ASSERT_TRUE( status );
status = file.load< double, double, Devices::Cuda >( newCudaDoubleData, 1 );
ASSERT_TRUE( status );
cudaMemcpy( &newIntData, cudaMemcpy( &newIntData,
newCudaIntData, newCudaIntData,
sizeof( int ), sizeof( int ),
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment