diff --git a/CMakeLists.txt b/CMakeLists.txt index d532da251..67d4ae966 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -711,6 +711,8 @@ endif (WIN32) # build a library of package functionality (without and optionally with OpenMP support) add_library (wsjt_cxx STATIC ${wsjt_CSRCS} ${wsjt_CXXSRCS}) + +# build an OpenMP variant of the Fortran library routines add_library (wsjt_fort STATIC ${wsjt_FSRCS}) if (${OPENMP_FOUND} OR APPLE) add_library (wsjt_fort_omp STATIC ${wsjt_FSRCS}) @@ -721,10 +723,12 @@ if (${OPENMP_FOUND} OR APPLE) ) file (MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/fortran_modules_omp) if (APPLE) - # nasty hack to use OpenMP only on Fortran files - assumes gfortran being used + # On Mac we don't have working OpenMP support in the C/C++ + # compilers so we have to manually set the correct flags to get + # OpenMP support in jt9. set_target_properties (wsjt_fort_omp PROPERTIES - COMPILE_FLAGS "-fopenmp" + COMPILE_FLAGS "-fopenmp" # assumes GNU style Fortran compiler ) endif (APPLE) endif (${OPENMP_FOUND} OR APPLE) @@ -746,28 +750,29 @@ add_executable (jt9code lib/jt9code.f90 wsjtx.rc) target_link_libraries (jt9code wsjt_fort wsjt_cxx) add_executable (jt9 lib/jt9.f90 lib/jt9a.f90 lib/jt9b.f90 lib/jt9c.f90 ${jt9_CXXSRCS} wsjtx.rc) -target_link_libraries (jt9 wsjt_fort wsjt_cxx ${FFTW3_LIBRARIES}) qt5_use_modules (jt9 Core) - if (${OPENMP_FOUND} OR APPLE) - add_executable (jt9_omp lib/jt9.f90 lib/jt9a.f90 lib/jt9b.f90 lib/jt9c.f90 ${jt9_CXXSRCS} wsjtx.rc) if (APPLE) - set_target_properties (jt9_omp + # On Mac we don't have working OpenMP support in the C/C++ + # compilers so we have to manually set the correct linking flags + # and libraries to get OpenMP support in jt9. + set_target_properties (jt9 PROPERTIES - COMPILE_FLAGS "-fopenmp" + COMPILE_FLAGS "-fopenmp" # assumes GNU style Fortran compiler Fortran_MODULE_DIRECTORY ${CMAKE_BINARY_DIR}/fortran_modules_omp - LINK_LIBRARIES "gomp;gcc_s.1" + LINK_LIBRARIES "gomp;gcc_s.1" # assume GNU libgcc OpenMP ) else (APPLE) - set_target_properties (jt9_omp + set_target_properties (jt9 PROPERTIES COMPILE_FLAGS "${OpenMP_C_FLAGS}" LINK_FLAGS "${OpenMP_C_FLAGS}" Fortran_MODULE_DIRECTORY ${CMAKE_BINARY_DIR}/fortran_modules_omp ) endif (APPLE) - target_link_libraries (jt9_omp wsjt_fort_omp wsjt_cxx ${FFTW3_LIBRARIES}) - qt5_use_modules (jt9_omp Core) + target_link_libraries (jt9 wsjt_fort_omp wsjt_cxx ${FFTW3_LIBRARIES}) +else (${OPENMP_FOUND} OR APPLE) + target_link_libraries (jt9 wsjt_fort wsjt_cxx ${FFTW3_LIBRARIES}) endif (${OPENMP_FOUND} OR APPLE) # build configuration dialog and transceiver interface test application @@ -844,13 +849,6 @@ install (TARGETS jt9 jt65code jt9code BUNDLE DESTINATION ${WSJT_BIN_DESTINATION} COMPONENT runtime ) -if (${OPENMP_FOUND} OR APPLE) - install (TARGETS jt9_omp - RUNTIME DESTINATION ${WSJT_BIN_DESTINATION} COMPONENT runtime - BUNDLE DESTINATION ${WSJT_BIN_DESTINATION} COMPONENT runtime - ) -endif (${OPENMP_FOUND} OR APPLE) - if (WSJT_INCLUDE_KVASD) install (PROGRAMS ${CMAKE_BINARY_DIR}/${KVASD_BINARY} diff --git a/mainwindow.cpp b/mainwindow.cpp index d2e38ec9f..32bece4ef 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -374,9 +374,19 @@ MainWindow::MainWindow(bool multiple, QSettings * settings, QSharedMemory *shdme QFile {m_config.temp_dir ().absoluteFilePath (".lock")}.open(QIODevice::ReadWrite); QStringList jt9_args { - "-s", QApplication::applicationName () - , "-w", "1" //FFTW patience - , "-m", "1" //FFTW threads + "-s", QApplication::applicationName () // shared memory key, + // includes rig-name + + , "-w", "2" //FFTW patience + + // The number of threads for FFTW specified here is chosen as + // three because that gives the best throughput of the large + // FFTs used in jt9. The count is the minimum of (the number + // available CPU threads less one) and three. This ensures that + // there is always at least one free CPU thread to run the other + // mode decoder in parallel. + , "-m", QString::number (qMin (qMax (QThread::idealThreadCount () - 1, 1), 3)) //FFTW threads + , "-e", QDir::toNativeSeparators (m_appDir) , "-a", QDir::toNativeSeparators (m_dataDir.absolutePath ()) , "-t", QDir::toNativeSeparators (m_config.temp_dir ().absolutePath ())