endif()
endif()
+
+option(GMX_NACL "Configure for Native Client builds" OFF)
+if (GMX_NACL)
+ list(APPEND GMX_EXTRA_LIBRARIES nosys)
+ set(GMX_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -lnosys")
+ set(GMX_NO_NICE 1)
+ set(GMX_NO_RENAME 1)
+endif()
+mark_as_advanced(GMX_NACL)
+
if(GMX_FAHCORE)
set(COREWRAP_INCLUDE_DIR "${CMAKE_SOURCE_DIR}/../corewrap" CACHE STRING
"Path to swindirect.h")
/* Ignore calls to nice(3) */
#cmakedefine GMX_NO_NICE
+/* Use if can't rename checkpoints */
+#cmakedefine GMX_NO_RENAME
+
/* Ignore calls to system(3) */
#cmakedefine GMX_NO_SYSTEM
set(GMX_BUILD_OWN_FFTW_OPTIMIZATION_CONFIGURATION --enable-sse2 CACHE INTERNAL "Optimization flags for FFTW compilation")
endif()
+# Allow cross-compiles
+if (TARGET_HOST)
+ set(GMX_BUILD_OWN_FFTW_TARGET --host=${TARGET_HOST})
+endif()
+
# Machinery for running the external project
set(EXTERNAL_FFTW_VERSION 3.3.2)
include(ExternalProject)
URL "http://www.fftw.org/fftw-${EXTERNAL_FFTW_VERSION}.tar.gz"
CONFIGURE_COMMAND <SOURCE_DIR>/configure --prefix=<INSTALL_DIR> --libdir=<INSTALL_DIR>/lib --disable-fortran
${GMX_BUILD_OWN_FFTW_SHARED_FLAG} ${GMX_BUILD_OWN_FFTW_OPTIMIZATION_CONFIGURATION}
- ${GMX_BUILD_OWN_FFTW_PREC})
+ ${GMX_BUILD_OWN_FFTW_PREC}
+ ${GMX_BUILD_OWN_FFTW_TARGET})
externalproject_get_property(fftwBuild INSTALL_DIR)
string(TOUPPER "${FFTW}" UPPERFFTW)
#ifdef ffclose
#undef ffclose
#endif
-#endif
-
-#ifndef GMX_FAHCORE
-#ifndef HAVE_PIPES
+#if (!defined(HAVE_PIPES) && !defined(__native_client__))
static FILE *popen(const char *nm, const char *mode)
{
gmx_impl("Sorry no pipes...");
return 0;
}
-#endif
-#endif
+#endif /* !defined(HAVE_PIPES) && !defined(__native_client__) */
+#endif /* GMX_FAHCORE */
int ffclose(FILE *fp)
{
fcReportProgress( ir->nsteps, step );
}
+#if defined(__native_client__)
+ fcCheckin(MASTER(cr));
+#endif
+
/* sync bCPT and fc record-keeping */
if (bCPT && MASTER(cr))
{
#include "network.h"
#include "gmx_random.h"
#include "checkpoint.h"
+#include "main.h"
#include "string2.h"
#include <fcntl.h>
if (!bRead)
{
snew(fhost, 255);
-#ifdef HAVE_UNISTD_H
- if (gethostname(fhost, 255) != 0)
- {
- sprintf(fhost, "unknown");
- }
-#else
- sprintf(fhost, "unknown");
-#endif
+ gmx_gethostname(fhost, 255);
}
do_cpt_string_err(xd, bRead, "GROMACS version", version, list);
do_cpt_string_err(xd, bRead, "GROMACS build time", btime, list);
npmenodes = 0;
}
+#ifndef GMX_NO_RENAME
/* make the new temporary filename */
snew(fntemp, strlen(fn)+5+STEPSTRSIZE);
strcpy(fntemp, fn);
sprintf(suffix, "_%s%s", "step", gmx_step_str(step, sbuf));
strcat(fntemp, suffix);
strcat(fntemp, fn+strlen(fn) - strlen(ftp2ext(fn2ftp(fn))) - 1);
-
+#else
+ /* if we can't rename, we just overwrite the cpt file.
+ * dangerous if interrupted.
+ */
+ snew(fntemp, strlen(fn));
+ strcpy(fntemp, fn);
+#endif
time(&now);
gmx_ctime_r(&now, timebuf, STRLEN);
/* we don't move the checkpoint if the user specified they didn't want it,
or if the fsyncs failed */
+#ifndef GMX_NO_RENAME
if (!bNumberAndKeep && !ret)
{
if (gmx_fexist(fn))
gmx_file("Cannot rename checkpoint file; maybe you are out of disk space?");
}
}
+#endif /* GMX_NO_RENAME */
sfree(outputfiles);
sfree(fntemp);
t_fileio *chksum_file;
FILE * fplog = *pfplog;
unsigned char digest[16];
-#ifndef GMX_NATIVE_WINDOWS
+#if !defined __native_client__ && !defined GMX_NATIVE_WINDOWS
struct flock fl; /* don't initialize here: the struct order is OS
dependent! */
#endif
" while the simulation uses %d SD or BD nodes,\n"
" continuation will be exact, except for the random state\n\n";
-#ifndef GMX_NATIVE_WINDOWS
+#if !defined __native_client__ && !defined GMX_NATIVE_WINDOWS
fl.l_type = F_WRLCK;
fl.l_whence = SEEK_SET;
fl.l_start = 0;
* will succeed, but a second process can also lock the file.
* We should probably try to detect this.
*/
-#ifndef GMX_NATIVE_WINDOWS
- if (fcntl(fileno(gmx_fio_getfp(chksum_file)), F_SETLK, &fl)
- == -1)
-#else
+#if defined __native_client__
+ errno = ENOSYS;
+ if (1)
+
+#elif defined GMX_NATIVE_WINDOWS
if (_locking(fileno(gmx_fio_getfp(chksum_file)), _LK_NBLCK, LONG_MAX) == -1)
+#else
+ if (fcntl(fileno(gmx_fio_getfp(chksum_file)), F_SETLK, &fl) == -1)
#endif
{
if (errno == ENOSYS)
#else
fprintf(fp, "Precision: single\n");
#endif
- fprintf(fp, "Memory model: %lu bit\n", 8*sizeof(void *));
+ fprintf(fp, "Memory model: %u bit\n", (unsigned)(8*sizeof(void *)));
#ifdef GMX_THREAD_MPI
fprintf(fp, "MPI library: thread_mpi\n");
if (rank_local == 0)
{
- char detection_error[STRLEN], sbuf[STRLEN];
+ char detection_error[STRLEN] = "", sbuf[STRLEN];
if (detect_cuda_gpus(&hwinfo_g->gpu_info, detection_error) != 0)
{
}
-char *gmx_gethostname(char *name, size_t len)
+int gmx_gethostname(char *name, size_t len)
{
if (len < 8)
{
gmx_incons("gmx_gethostname called with len<8");
}
-#ifdef HAVE_UNISTD_H
+#if defined(HAVE_UNISTD_H) && !defined(__native_client__)
if (gethostname(name, len-1) != 0)
{
strncpy(name, "unknown", 8);
+ return -1;
}
+ return 0;
#else
strncpy(name, "unknown", 8);
+ return -1;
#endif
-
- return name;
}
#include "smalloc.h"
#include "gmx_fatal.h"
#include "macros.h"
+#include "main.h"
#include "string2.h"
#include "gromacs/fileio/futil.h"
#ifdef HAVE_PWD_H
uid = getuid();
pw = getpwuid(uid);
- gh = gethostname(buf, 255);
+ gh = gmx_gethostname(buf, 255);
/* pw returns null on error (e.g. compute nodes lack /etc/passwd) */
user = pw ? pw->pw_name : unk;
#else
library. It contains the definitions for all the internal data structures
and the prototypes for all the internal functions that aren't static. */
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
#ifdef HAVE_UNISTD_H
#include <unistd.h>
int MPI_Buffer_attach(void* buffer, int size)
{
+ return 0;
}
int MPI_Buffer_detach(void* buffer_addr, int* size)
{
+ return 0;
}
goto err;
}
}
+ ret = pthread_mutex_unlock( &(mutex_init) );
}
- ret = pthread_mutex_unlock( &(mutex_init) );
return ret;
err:
pthread_mutex_unlock( &(mutex_init) );
int tMPI_Thread_cancel(tMPI_Thread_t thread)
{
+ #ifdef __native_client__
+ return ENOSYS;
+ #endif
return pthread_cancel(thread->th);
}
extern "C" {
#endif
-char *gmx_gethostname(char *name, size_t len);
+int gmx_gethostname(char *name, size_t len);
/* Sets the hostname to the value given by gethostname, if available,
* and to "unknown" otherwise. name should have at least size len.
- * Returns name.
+ * Returns 0 on success, -1 on error.
*/
void gmx_log_open(const char *fn, const t_commrec *cr,
}
#ifdef GMX_FAHCORE
- fcRegisterSteps(inputrec->nsteps, inputrec->init_step);
+ if (MASTER(cr))
+ {
+ fcRegisterSteps(inputrec->nsteps, inputrec->init_step);
+ }
#endif
/* NMR restraints must be initialized before load_checkpoint,