Loading CMakeLists.txt +0 −12 Original line number Diff line number Diff line Loading @@ -38,18 +38,6 @@ else() AddCompilerFlag( "-std=gnu++0x" ) endif() ##### # Check for bzip2 # find_package(BZip2) if( BZIP2_FOUND ) set( HAVE_LIBBZ2 "#define HAVE_BZIP2" ) include_directories("${BZIP2_INCLUDE_DIR}") else( BZIP2_FOUND ) set( HAVE_LIBBZ2 "// #define HAVE_BZIP2" ) endif( BZIP2_FOUND ) ##### # Check for CUDA # Loading src/core/tnlFile.h +37 −64 Original line number Diff line number Diff line Loading @@ -23,9 +23,6 @@ #include <stdio.h> #include <stdlib.h> #include <tnlConfig.h> #ifdef HAVE_BZIP2 #include <bzlib.h> #endif #ifdef HAVE_CUDA #include <cuda_runtime.h> #endif Loading @@ -40,10 +37,6 @@ using namespace std; enum tnlCompression { tnlCompressionNone = 0, tnlCompressionBzip2, tnlCompressionGzip }; enum tnlIOMode { tnlUndefinedMode = 0, tnlReadMode = 1, tnlWriteMode = 2 }; Loading @@ -63,8 +56,6 @@ class tnlFile { tnlIOMode mode; tnlCompression compression; FILE* file; bool fileOK; Loading @@ -75,33 +66,27 @@ class tnlFile long int readElements; #ifdef HAVE_BZIP2 BZFILE* bzFile; #endif bool checkBz2Error( int bzerror ) const; public: tnlFile(); bool open( const tnlString& fileName, const tnlIOMode mode, const tnlCompression compression = tnlCompressionBzip2 ); const tnlIOMode mode ); const tnlString& getFileName() const { return fileName; return this->fileName; } long int getReadElements() const { return readElements; return this->readElements; } long int getWrittenElements() const { return writtenElements; return this->writtenElements; } // TODO: this does not work for constant types Loading Loading @@ -169,21 +154,21 @@ bool tnlFile :: read( Type* buffer, cerr << "File " << fileName << " was not opened for reading. " << endl; return false; } #ifdef HAVE_BZIP2 int bzerror; int bytes_read( 0 ); this->readElements = 0; const Index host_buffer_size = :: Min( ( Index ) ( tnlFileGPUvsCPUTransferBufferSize / sizeof( Type ) ), elements ); void* host_buffer( 0 ); if( Device :: getDeviceType() == "tnlHost" ) { bytes_read = BZ2_bzRead( &bzerror, bzFile, buffer, elements * sizeof( Type ) ); if( bzerror == BZ_OK || bzerror == BZ_STREAM_END ) readElements = bytes_read / sizeof( Type ); return checkBz2Error( bzerror ); if( fread( buffer, sizeof( Type ), elements, file ) != elements ) return false; this->readElements = elements; return true; } if( Device :: getDeviceType() == "tnlCuda" ) { Loading @@ -209,15 +194,12 @@ bool tnlFile :: read( Type* buffer, while( readElements < elements ) { int transfer = :: Min( ( Index ) ( elements - readElements ), host_buffer_size ); int bytesRead = BZ2_bzRead( &bzerror, bzFile, host_buffer, transfer * sizeof( Type ) ); if( ! checkBz2Error( bzerror) ) { free( host_buffer ); if( fread( host_buffer, sizeof( Type ), transfer, file ) != transfer * sizeof( Type ) ) return false; } if( cudaMemcpy( ( void* ) & ( buffer[ readElements ] ), host_buffer, bytesRead, Loading @@ -238,10 +220,6 @@ bool tnlFile :: read( Type* buffer, return false; #endif } #else cerr << "Bzip2 compression is not supported on this system." << endl; return false; #endif return true; }; Loading @@ -259,20 +237,24 @@ bool tnlFile :: write( const Type* buffer, cerr << "File " << fileName << " was not opened for writing. " << endl; return false; } #ifdef HAVE_BZIP2 int bzerror; Type* buf = const_cast< Type* >( buffer ); void* host_buffer( 0 ); Index writtenElements( 0 ); this->writtenElements = 0; const Index host_buffer_size = :: Min( ( Index ) ( tnlFileGPUvsCPUTransferBufferSize / sizeof( Type ) ), elements ); if( Device :: getDeviceType() == "tnlHost" ) { BZ2_bzWrite( &bzerror, bzFile, ( void* ) buf, elements * sizeof( Type ) ); return checkBz2Error( bzerror ); if( fwrite( buf, sizeof( Type ), elements, this->file ) != elements ) { cerr << "Writing to the file " << this->fileName << " failed." << endl; return false; } this->writtenElements = elements; return true; } if( Device :: getDeviceType() == "tnlCuda" ) { Loading Loading @@ -306,15 +288,11 @@ bool tnlFile :: write( const Type* buffer, free( host_buffer ); return false; } BZ2_bzWrite( &bzerror, bzFile, ( void* ) host_buffer, transfer * sizeof( Type ) ); if( ! checkBz2Error( bzerror ) ) { free( host_buffer ); if( fwrite( host_buffer, sizeof( Type ), transfer, this->file ) != transfer*sizeof( Type ) ) return false; } writtenElements += transfer; } free( host_buffer ); Loading @@ -324,11 +302,6 @@ bool tnlFile :: write( const Type* buffer, return false; #endif } #else cerr << "Bzip2 compression is not supported on this system." << endl; return false; #endif return true; }; Loading src/implementation/core/tnlFile.cpp +17 −125 Original line number Diff line number Diff line Loading @@ -21,7 +21,6 @@ int tnlFile :: verbose = 0; tnlFile :: tnlFile() : mode( tnlUndefinedMode ), compression( tnlCompressionNone ), file( NULL ), fileOK( false ), writtenElements( 0 ), Loading @@ -30,11 +29,9 @@ tnlFile :: tnlFile() } bool tnlFile :: open( const tnlString& fileName, const tnlIOMode mode, const tnlCompression compression ) const tnlIOMode mode ) { this->fileName = fileName; this -> compression = compression; if( verbose ) { cout << "Opening file " << fileName; Loading @@ -43,12 +40,6 @@ bool tnlFile :: open( const tnlString& fileName, else cout << " for writing ... " << endl; } switch( compression ) { case tnlCompressionNone: break; case tnlCompressionBzip2: #ifdef HAVE_BZIP2 if( mode == tnlReadMode ) file = fopen( fileName. getString(), "r" ); if( mode == tnlWriteMode ) Loading @@ -59,120 +50,21 @@ bool tnlFile :: open( const tnlString& fileName, perror( "" ); return false; } int bzerror; if( mode == tnlReadMode) bzFile = BZ2_bzReadOpen( &bzerror, file, 0, // int verbosity, 0, // int small, NULL, // void *unused, 0 //int nUnused ); if( mode == tnlWriteMode ) bzFile = BZ2_bzWriteOpen( &bzerror, file, 9, //int blockSize100k, 0, //int verbosity, 0 //int workFactor ); if( bzerror == BZ_OK ) { fileOK = true; this->fileOK = true; this->mode = mode; return true; } if( bzerror == BZ_CONFIG_ERROR ) { cerr << "ERROR: Cannot open the file " << fileName << " because the bzip2 library has been mis-compiled." << endl; return false; } if( bzerror == BZ_MEM_ERROR ) { cerr << "ERROR: Cannot open the file " << fileName << " because of insufficient memory." << endl; return false; } cerr << "ERROR: Unknown error occured while I tried to open the file " << fileName << endl; checkBz2Error( bzerror ); return false; #else cerr << "Bzip2 compression is not supported on this system." << endl; return false; #endif break; case tnlCompressionGzip: break; } return false; } bool tnlFile :: close() { if( verbose ) cout << "Closing the file " << getFileName() << " ... " << endl; switch( compression ) { case tnlCompressionNone: break; case tnlCompressionBzip2: #ifdef HAVE_BZIP2 if( ! fileOK ) return false; int bzerror; if( mode == tnlReadMode ) BZ2_bzReadClose( &bzerror, bzFile ); if( mode == tnlWriteMode ) BZ2_bzWriteClose( &bzerror, bzFile, 0, // int abandon, 0, // unsigned int* nbytes_in, 0 // unsigned int* nbytes_out ); mode = tnlUndefinedMode; if( bzerror != BZ_OK ) cerr << "ERROR: I was not able to close the file " << fileName << endl; if( fclose( file ) != 0 ) { cerr << "I was not able to close the file " << fileName << " properly!" << endl; return false; } #else cerr << "Bzip2 compression is not supported on this system." << endl; return false; #endif break; case tnlCompressionGzip: break; } readElements = writtenElements = 0; return true; }; bool tnlFile :: checkBz2Error( int bzerror ) const { switch( bzerror ) { case BZ_OK: return true; case BZ_STREAM_END: return true; case BZ_CONFIG_ERROR: cerr << "The BZ2 library has been mis-compiled" << endl; return false; case BZ_PARAM_ERROR: cerr << "It is a libbz2 parameter error. It must be a bug in the program." << endl; return false; case BZ_IO_ERROR: cerr << "It is a I/O error." << endl; return false; case BZ_MEM_ERROR: cerr << "Insufficient memory for I/O operation." << endl; return false; case BZ_UNEXPECTED_EOF: cerr << "Unexpected end of file." << endl; return false; default: cerr << "Unknown error with code " << bzerror << endl; } }; src/implementation/schemes/CMakeLists.txt +1 −0 Original line number Diff line number Diff line ADD_SUBDIRECTORY( gradient ) ADD_SUBDIRECTORY( diffusion ) ADD_SUBDIRECTORY( euler ) ADD_SUBDIRECTORY( navier-stokes ) SET( CURRENT_DIR ${CMAKE_SOURCE_DIR}/src/implementation/schemes ) Loading src/implementation/schemes/navier-stokes/CMakeLists.txt 0 → 100755 +15 −0 Original line number Diff line number Diff line set( headers tnlNavierStokes_impl.h ) SET( CURRENT_DIR ${CMAKE_SOURCE_DIR}/src/implementation/schemes/navier-stokes ) if( BUILD_CUDA) set( tnl_implementation_schemes_navier_stokes_CUDA__SOURCES ${common_SOURCES} PARENT_SCOPE ) endif() set( tnl_implementation_schemes_navier_stokes_SOURCES ${common_SOURCES} PARENT_SCOPE ) INSTALL( FILES ${headers} DESTINATION include/tnl-${tnlVersion}/implementation/schemes/navier-stokes ) Loading
CMakeLists.txt +0 −12 Original line number Diff line number Diff line Loading @@ -38,18 +38,6 @@ else() AddCompilerFlag( "-std=gnu++0x" ) endif() ##### # Check for bzip2 # find_package(BZip2) if( BZIP2_FOUND ) set( HAVE_LIBBZ2 "#define HAVE_BZIP2" ) include_directories("${BZIP2_INCLUDE_DIR}") else( BZIP2_FOUND ) set( HAVE_LIBBZ2 "// #define HAVE_BZIP2" ) endif( BZIP2_FOUND ) ##### # Check for CUDA # Loading
src/core/tnlFile.h +37 −64 Original line number Diff line number Diff line Loading @@ -23,9 +23,6 @@ #include <stdio.h> #include <stdlib.h> #include <tnlConfig.h> #ifdef HAVE_BZIP2 #include <bzlib.h> #endif #ifdef HAVE_CUDA #include <cuda_runtime.h> #endif Loading @@ -40,10 +37,6 @@ using namespace std; enum tnlCompression { tnlCompressionNone = 0, tnlCompressionBzip2, tnlCompressionGzip }; enum tnlIOMode { tnlUndefinedMode = 0, tnlReadMode = 1, tnlWriteMode = 2 }; Loading @@ -63,8 +56,6 @@ class tnlFile { tnlIOMode mode; tnlCompression compression; FILE* file; bool fileOK; Loading @@ -75,33 +66,27 @@ class tnlFile long int readElements; #ifdef HAVE_BZIP2 BZFILE* bzFile; #endif bool checkBz2Error( int bzerror ) const; public: tnlFile(); bool open( const tnlString& fileName, const tnlIOMode mode, const tnlCompression compression = tnlCompressionBzip2 ); const tnlIOMode mode ); const tnlString& getFileName() const { return fileName; return this->fileName; } long int getReadElements() const { return readElements; return this->readElements; } long int getWrittenElements() const { return writtenElements; return this->writtenElements; } // TODO: this does not work for constant types Loading Loading @@ -169,21 +154,21 @@ bool tnlFile :: read( Type* buffer, cerr << "File " << fileName << " was not opened for reading. " << endl; return false; } #ifdef HAVE_BZIP2 int bzerror; int bytes_read( 0 ); this->readElements = 0; const Index host_buffer_size = :: Min( ( Index ) ( tnlFileGPUvsCPUTransferBufferSize / sizeof( Type ) ), elements ); void* host_buffer( 0 ); if( Device :: getDeviceType() == "tnlHost" ) { bytes_read = BZ2_bzRead( &bzerror, bzFile, buffer, elements * sizeof( Type ) ); if( bzerror == BZ_OK || bzerror == BZ_STREAM_END ) readElements = bytes_read / sizeof( Type ); return checkBz2Error( bzerror ); if( fread( buffer, sizeof( Type ), elements, file ) != elements ) return false; this->readElements = elements; return true; } if( Device :: getDeviceType() == "tnlCuda" ) { Loading @@ -209,15 +194,12 @@ bool tnlFile :: read( Type* buffer, while( readElements < elements ) { int transfer = :: Min( ( Index ) ( elements - readElements ), host_buffer_size ); int bytesRead = BZ2_bzRead( &bzerror, bzFile, host_buffer, transfer * sizeof( Type ) ); if( ! checkBz2Error( bzerror) ) { free( host_buffer ); if( fread( host_buffer, sizeof( Type ), transfer, file ) != transfer * sizeof( Type ) ) return false; } if( cudaMemcpy( ( void* ) & ( buffer[ readElements ] ), host_buffer, bytesRead, Loading @@ -238,10 +220,6 @@ bool tnlFile :: read( Type* buffer, return false; #endif } #else cerr << "Bzip2 compression is not supported on this system." << endl; return false; #endif return true; }; Loading @@ -259,20 +237,24 @@ bool tnlFile :: write( const Type* buffer, cerr << "File " << fileName << " was not opened for writing. " << endl; return false; } #ifdef HAVE_BZIP2 int bzerror; Type* buf = const_cast< Type* >( buffer ); void* host_buffer( 0 ); Index writtenElements( 0 ); this->writtenElements = 0; const Index host_buffer_size = :: Min( ( Index ) ( tnlFileGPUvsCPUTransferBufferSize / sizeof( Type ) ), elements ); if( Device :: getDeviceType() == "tnlHost" ) { BZ2_bzWrite( &bzerror, bzFile, ( void* ) buf, elements * sizeof( Type ) ); return checkBz2Error( bzerror ); if( fwrite( buf, sizeof( Type ), elements, this->file ) != elements ) { cerr << "Writing to the file " << this->fileName << " failed." << endl; return false; } this->writtenElements = elements; return true; } if( Device :: getDeviceType() == "tnlCuda" ) { Loading Loading @@ -306,15 +288,11 @@ bool tnlFile :: write( const Type* buffer, free( host_buffer ); return false; } BZ2_bzWrite( &bzerror, bzFile, ( void* ) host_buffer, transfer * sizeof( Type ) ); if( ! checkBz2Error( bzerror ) ) { free( host_buffer ); if( fwrite( host_buffer, sizeof( Type ), transfer, this->file ) != transfer*sizeof( Type ) ) return false; } writtenElements += transfer; } free( host_buffer ); Loading @@ -324,11 +302,6 @@ bool tnlFile :: write( const Type* buffer, return false; #endif } #else cerr << "Bzip2 compression is not supported on this system." << endl; return false; #endif return true; }; Loading
src/implementation/core/tnlFile.cpp +17 −125 Original line number Diff line number Diff line Loading @@ -21,7 +21,6 @@ int tnlFile :: verbose = 0; tnlFile :: tnlFile() : mode( tnlUndefinedMode ), compression( tnlCompressionNone ), file( NULL ), fileOK( false ), writtenElements( 0 ), Loading @@ -30,11 +29,9 @@ tnlFile :: tnlFile() } bool tnlFile :: open( const tnlString& fileName, const tnlIOMode mode, const tnlCompression compression ) const tnlIOMode mode ) { this->fileName = fileName; this -> compression = compression; if( verbose ) { cout << "Opening file " << fileName; Loading @@ -43,12 +40,6 @@ bool tnlFile :: open( const tnlString& fileName, else cout << " for writing ... " << endl; } switch( compression ) { case tnlCompressionNone: break; case tnlCompressionBzip2: #ifdef HAVE_BZIP2 if( mode == tnlReadMode ) file = fopen( fileName. getString(), "r" ); if( mode == tnlWriteMode ) Loading @@ -59,120 +50,21 @@ bool tnlFile :: open( const tnlString& fileName, perror( "" ); return false; } int bzerror; if( mode == tnlReadMode) bzFile = BZ2_bzReadOpen( &bzerror, file, 0, // int verbosity, 0, // int small, NULL, // void *unused, 0 //int nUnused ); if( mode == tnlWriteMode ) bzFile = BZ2_bzWriteOpen( &bzerror, file, 9, //int blockSize100k, 0, //int verbosity, 0 //int workFactor ); if( bzerror == BZ_OK ) { fileOK = true; this->fileOK = true; this->mode = mode; return true; } if( bzerror == BZ_CONFIG_ERROR ) { cerr << "ERROR: Cannot open the file " << fileName << " because the bzip2 library has been mis-compiled." << endl; return false; } if( bzerror == BZ_MEM_ERROR ) { cerr << "ERROR: Cannot open the file " << fileName << " because of insufficient memory." << endl; return false; } cerr << "ERROR: Unknown error occured while I tried to open the file " << fileName << endl; checkBz2Error( bzerror ); return false; #else cerr << "Bzip2 compression is not supported on this system." << endl; return false; #endif break; case tnlCompressionGzip: break; } return false; } bool tnlFile :: close() { if( verbose ) cout << "Closing the file " << getFileName() << " ... " << endl; switch( compression ) { case tnlCompressionNone: break; case tnlCompressionBzip2: #ifdef HAVE_BZIP2 if( ! fileOK ) return false; int bzerror; if( mode == tnlReadMode ) BZ2_bzReadClose( &bzerror, bzFile ); if( mode == tnlWriteMode ) BZ2_bzWriteClose( &bzerror, bzFile, 0, // int abandon, 0, // unsigned int* nbytes_in, 0 // unsigned int* nbytes_out ); mode = tnlUndefinedMode; if( bzerror != BZ_OK ) cerr << "ERROR: I was not able to close the file " << fileName << endl; if( fclose( file ) != 0 ) { cerr << "I was not able to close the file " << fileName << " properly!" << endl; return false; } #else cerr << "Bzip2 compression is not supported on this system." << endl; return false; #endif break; case tnlCompressionGzip: break; } readElements = writtenElements = 0; return true; }; bool tnlFile :: checkBz2Error( int bzerror ) const { switch( bzerror ) { case BZ_OK: return true; case BZ_STREAM_END: return true; case BZ_CONFIG_ERROR: cerr << "The BZ2 library has been mis-compiled" << endl; return false; case BZ_PARAM_ERROR: cerr << "It is a libbz2 parameter error. It must be a bug in the program." << endl; return false; case BZ_IO_ERROR: cerr << "It is a I/O error." << endl; return false; case BZ_MEM_ERROR: cerr << "Insufficient memory for I/O operation." << endl; return false; case BZ_UNEXPECTED_EOF: cerr << "Unexpected end of file." << endl; return false; default: cerr << "Unknown error with code " << bzerror << endl; } };
src/implementation/schemes/CMakeLists.txt +1 −0 Original line number Diff line number Diff line ADD_SUBDIRECTORY( gradient ) ADD_SUBDIRECTORY( diffusion ) ADD_SUBDIRECTORY( euler ) ADD_SUBDIRECTORY( navier-stokes ) SET( CURRENT_DIR ${CMAKE_SOURCE_DIR}/src/implementation/schemes ) Loading
src/implementation/schemes/navier-stokes/CMakeLists.txt 0 → 100755 +15 −0 Original line number Diff line number Diff line set( headers tnlNavierStokes_impl.h ) SET( CURRENT_DIR ${CMAKE_SOURCE_DIR}/src/implementation/schemes/navier-stokes ) if( BUILD_CUDA) set( tnl_implementation_schemes_navier_stokes_CUDA__SOURCES ${common_SOURCES} PARENT_SCOPE ) endif() set( tnl_implementation_schemes_navier_stokes_SOURCES ${common_SOURCES} PARENT_SCOPE ) INSTALL( FILES ${headers} DESTINATION include/tnl-${tnlVersion}/implementation/schemes/navier-stokes )