check_function_exists(rsqrt HAVE_RSQRT)
check_function_exists(rsqrtf HAVE_RSQRTF)
check_function_exists(sqrtf HAVE_SQRTF)
+check_function_exists(nice HAVE_NICE)
include(CheckLibraryExists)
check_library_exists(m sqrt "" HAVE_LIBM)
include(TestBigEndian)
test_big_endian(GMX_INTEGER_BIG_ENDIAN)
+set(GMX_USE_NICE 0)
+if (HAVE_UNISTD_H AND HAVE_NICE)
+ set(GMX_USE_NICE 1)
+endif()
+
# Management of GROMACS options for specific toolchains should go
# here. Because the initial settings for some of the main options have
# already happened, but things like library detection and MPI compiler
if (GMX_NACL)
list(APPEND GMX_EXTRA_LIBRARIES nosys)
set(GMX_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -lnosys")
- set(GMX_NO_NICE 1)
+ # TODO: Is this still necessary with the check for its presence?
+ set(GMX_USE_NICE 0)
set(GMX_NO_RENAME 1)
endif()
mark_as_advanced(GMX_NACL)
/* Use OpenMP multithreading */
#cmakedefine GMX_OPENMP
-/* Ignore calls to nice(3) */
-#cmakedefine GMX_NO_NICE
+/* Can and should use nice(3) to set priority */
+#cmakedefine GMX_USE_NICE
/* Use if can't rename checkpoints */
#cmakedefine GMX_NO_RENAME
#include <string>
#include <utility>
-#ifdef HAVE_UNISTD_H
-#include <unistd.h>
-#endif
-
#include "gromacs/commandline/cmdlinehelpcontext.h"
#include "gromacs/commandline/cmdlineinit.h"
#include "gromacs/commandline/cmdlinemodule.h"
#include "gromacs/utility/fatalerror.h"
#include "gromacs/utility/gmxassert.h"
#include "gromacs/utility/stringutil.h"
+#include "gromacs/utility/sysinfo.h"
#include "cmdlinehelpmodule.h"
#include "cmdlinemodulemanager-impl.h"
fprintf(stderr, "Will write debug log file: %s\n", filename.c_str());
gmx_init_debug(optionsHolder.debugLevel(), filename.c_str());
}
-#if defined(HAVE_UNISTD_H) && !defined(GMX_NO_NICE) && !defined(__MINGW32__)
// Set the nice level unless disabled in the configuration.
if (optionsHolder.niceLevel() != 0)
{
static bool bNiceSet = false; // Only set it once.
if (!bNiceSet)
{
- if (nice(optionsHolder.niceLevel()) == -1)
- {
- // Do nothing, but use the return value to avoid warnings.
- }
+ // TODO: Diagnostic if this fails and the user explicitly requested it.
+ gmx_set_nice(optionsHolder.niceLevel());
bNiceSet = true;
}
}
-#endif
int rc = 0;
if (!(module == impl_->helpModule_ && !bMaster))
#include "fflibutil.h"
-#include "config.h"
-
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-#include <fcntl.h>
-#include <sys/stat.h>
-#include <sys/types.h>
-
-#ifdef HAVE_UNISTD_H
-#include <unistd.h>
-#endif
-
#include "gromacs/legacyheaders/network.h"
#include "gromacs/utility/cstringutil.h"
#include "gromacs/utility/exceptions.h"
#include <stdio.h>
#include <string.h>
-#ifdef HAVE_UNISTD_H
-#include <unistd.h>
-#endif
-
#include "gromacs/commandline/pargs.h"
#include "gromacs/fileio/enxio.h"
#include "gromacs/fileio/gmxfio.h"
#include <unistd.h>
#endif
+#include "gromacs/utility/basedefinitions.h"
#include "gromacs/utility/gmxassert.h"
namespace
time_t clock = time(NULL);
gmx_ctime_r(&clock, buf, len);
}
+
+int gmx_set_nice(int level)
+{
+#ifdef GMX_USE_NICE
+ // TODO: This may not be reliable, but currently the return value is not
+ // used.
+ if (nice(level) != -1)
+ {
+ return 0;
+ }
+#else
+ GMX_UNUSED_VALUE(level);
+#endif
+ return -1;
+}
*/
void gmx_format_current_time(char *buf, size_t len);
+/*! \brief
+ * Wrapper for nice().
+ *
+ * Does not throw.
+ */
+int gmx_set_nice(int level);
+
/*! \} */
#ifdef __cplusplus
#include <string.h>
#include <algorithm>
-#ifdef HAVE_UNISTD_H
-#include <unistd.h>
-#endif
#include "gromacs/essentialdynamics/edsam.h"
#include "gromacs/ewald/ewald-util.h"