void selectDeviceBasedOnMpiRank() { #ifdef WALBERLA_BUILD_WITH_MPI int deviceCount; WALBERLA_CUDA_CHECK( cudaGetDeviceCount( &deviceCount )); WALBERLA_LOG_INFO_ON_ROOT( "Selecting CUDA device depending on MPI Rank" ); MPI_Info info; MPI_Info_create( &info ); MPI_Comm newCommunicator; MPI_Comm_split_type(MPI_COMM_WORLD, MPI_COMM_TYPE_SHARED, 0, info, &newCommunicator ); int processesOnNode; int rankOnNode; MPI_Comm_size( newCommunicator, &processesOnNode ); MPI_Comm_rank( newCommunicator, &rankOnNode ); if ( deviceCount == processesOnNode ) { WALBERLA_CUDA_CHECK( cudaSetDevice( rankOnNode )); } else if ( deviceCount > processesOnNode ) { WALBERLA_LOG_WARNING( "Not using all available GPUs on node. Processes on node " << processesOnNode << " available GPUs on node " << deviceCount ); WALBERLA_CUDA_CHECK( cudaSetDevice( rankOnNode )); } else { WALBERLA_LOG_WARNING( "Too many processes started per node - should be one per GPU. Number of processes per node " << processesOnNode << ", available GPUs on node " << deviceCount ); WALBERLA_CUDA_CHECK( cudaSetDevice( rankOnNode % deviceCount )); } #endif }
bool ExprSystemInitFunction::parse( const Config::BlockHandle & config ) { // parse expressions from config and compile them exprtk::parser<real_t> parser; bool valid = true; const std::string ux_expr_str = config.getParameter<std::string>( "u_x" , "0.0" ); if( !parser.compile( ux_expr_str, (*expr_)[ "u_x" ] ) ) { WALBERLA_LOG_WARNING( "Error in expression for u_x\n" << "Error : " << parser.error() << "\n" << "Expression: " << ux_expr_str ); valid = false; } const std::string uy_expr_str = config.getParameter<std::string>( "u_y" , "0.0" ); if( !parser.compile( uy_expr_str, (*expr_)[ "u_y" ] ) ) { WALBERLA_LOG_WARNING( "Error in expression for u_y\n" << "Error : " << parser.error() << "\n" << "Expression: " << uy_expr_str ); valid = false; } const std::string uz_expr_str = config.getParameter<std::string>( "u_z" , "0.0" ); if( !parser.compile( uz_expr_str, (*expr_)[ "u_z" ] ) ) { WALBERLA_LOG_WARNING( "Error in expression for u_z\n" << "Error : " << parser.error() << "\n" << "Expression: " << uz_expr_str ); valid = false; } const std::string rho_expr_str = config.getParameter<std::string>( "rho" , "1.0" ); if( !parser.compile( rho_expr_str, (*expr_)[ "rho" ] ) ) { WALBERLA_LOG_WARNING( "Error in expression for rho\n" << "Error : " << parser.error() << "\n" << "Expression: " << rho_expr_str ); valid = false; } return valid; }
GUI::GUI(timeloop::ITimeloop & timeloop, const shared_ptr<StructuredBlockForest> & blockForest, int& argc, char ** argv) : timeloop_( timeloop ), blockForest_( *blockForest ) { QCoreApplication::setOrganizationName( "FAU" ); QCoreApplication::setApplicationName ( "waLBerla" ); pImpl = new GuiImpl(); pImpl->app = new QApplication( argc, argv ); pImpl->mainWindow = new MainWindow( timeloop_, blockForest_, *this ); if ( lastInstance_ != NULL ) { WALBERLA_LOG_WARNING( "More than one GUI may lead to problems!"); } lastInstance_ = this; walberla::Abort::instance()->resetAbortFunction( &walberla::Abort::exceptionAbort ); }