| kspaceFirstOrder3D-OMP 1.0 The C++ implementation of the k-wave toolbox for the time-domain simulation of acoustic wave fields in 3D

- Main Page
- Classes
- Files

- File List
- File Members

main.cpp
Go to the documentation of this file.

    00001
    00566 #include <cstdlib>
    00567 #include <iostream>
    00568 #include <omp.h>
    00569 #include <exception>
    00570
    00571 #include <KSpaceSolver/KSpaceFirstOrder3DSolver.h>
    00572
    00573
    00574 using namespace std;
    00575
    00576
    00578 static const char * FMT_SmallSeparator = "--------------------------------\n";
    00579
    00586 int main(int argc, char** argv) {
    00587
    00588     // Create K-Space solver
    00589     TKSpaceFirstOrder3DSolver KSpaceSolver;
    00590
    00591    // print header
    00592     fprintf(stdout,"%s",FMT_SmallSeparator);
    00593     fprintf(stdout,"  %s\n",KSpaceSolver.GetCodeName().c_str());
    00594     fprintf(stdout,"%s",FMT_SmallSeparator);
    00595
    00596     // Create parameters and parse command line
    00597     TParameters* Parameters = TParameters::GetInstance();
    00598
    00599     Parameters->ParseCommandLine(argc,argv);
    00600         if (Parameters->IsVersion()){
    00601         KSpaceSolver.PrintFullNameCodeAndLicense(stdout);
    00602         return 0;
    00603     }
    00604
    00605
    00606     // set number of threads and bind them to cores
    00607     omp_set_num_threads(Parameters->GetNumberOfThreads());
    00608     setenv("OMP_PROC_BIND","TRUE",1);
    00609
    00610
    00611     fprintf(stdout, "Number of CPU threads:    %6d\n", Parameters->GetNumberOfThreads());
    00612     KSpaceSolver.PrintParametersOfSimulation(stdout);
    00613
    00614
    00615     fprintf(stdout,"%s",FMT_SmallSeparator);
    00616     fprintf(stdout,"........ Initialization ........\n");
    00617     fprintf(stdout,"Memory allocation ..........");
    00618     fflush(stdout);
    00619
    00620
    00621     // allocate memory
    00622     try {
    00623       KSpaceSolver.AllocateMemory();
    00624     } catch (exception e){
    00625         fprintf(stdout, "Failed!\nK-Wave panic: Not enough memory to run this simulation!\n%s\n",e.what());
    00626         fprintf(stderr, "K-Wave panic: Not enough memory to run this simulation! \n%s\n",e.what());
    00627         return EXIT_FAILURE;
    00628     }
    00629     fprintf(stdout, "Done\n");
    00630
    00631
    00632     // Load data from disk
    00633     fprintf(stdout, "Data loading................");
    00634     fflush(stdout);
    00635     try {
    00636       KSpaceSolver.LoadInputData();
    00637     }catch (ios::failure e) {
    00638         fprintf(stdout, "Failed!\nK-Wave panic: Data loading was not successful!\n%s\n",e.what());
    00639         fprintf(stderr, "K-Wave panic: Data loading was not successful! \n%s\n",e.what());
    00640         return EXIT_FAILURE;
    00641     }
    00642     fprintf(stdout, "Done\n");
    00643
    00644     fprintf(stdout,"Elapsed time:          %8.2fs\n",KSpaceSolver.GetDataLoadTime());
    00645
    00646     // start computation
    00647     fprintf(stdout,"%s",FMT_SmallSeparator);
    00648     fprintf(stdout, ".......... Computation .........\n");
    00649
    00650     KSpaceSolver.Compute();
    00651
    00652     fprintf(stdout,"%s",FMT_SmallSeparator);
    00653     fprintf(stdout, "............ Summary ...........\n");
    00654     fprintf(stdout, "Peak memory in use:   %8ldMB\n",KSpaceSolver.ShowMemoryUsageInMB());
    00655     fprintf(stdout, "Total execution time:  %8.2fs\n",KSpaceSolver.GetTotalTime());
    00656
    00657
    00658     fprintf(stdout,"%s",FMT_SmallSeparator);
    00659     fprintf(stdout,"       End of computation \n");
    00660     fprintf(stdout,"%s",FMT_SmallSeparator);
    00661
    00662     return  EXIT_SUCCESS;
    00663 }// end of main
    00664 //------------------------------------------------------------------------------
    00665

All Classes Files Functions Variables Typedefs Enumerations