Merge release-4-6 into master
authorRoland Schulz <roland@utk.edu>
Thu, 9 Jan 2014 18:48:12 +0000 (13:48 -0500)
committerRoland Schulz <roland@utk.edu>
Thu, 9 Jan 2014 19:03:24 +0000 (14:03 -0500)
Conflicts:
src/gromacs/gmxlib/checkpoint.c
src/kernel/genalg.c
src/programs/mdrun/md.c
             (moved change to trajectory_writing.c)

Change-Id: Ia9c8722c7fb80d48d8e40cec2af0cb93dc7e468e

15 files changed:
CMakeLists.txt
src/config.h.cmakein
src/contrib/fftw/CMakeLists.txt
src/gromacs/fileio/futil.cpp
src/gromacs/fileio/trajectory_writing.c
src/gromacs/gmxlib/checkpoint.c
src/gromacs/gmxlib/copyrite.cpp
src/gromacs/gmxlib/gmx_detect_hardware.c
src/gromacs/gmxlib/main.cpp
src/gromacs/gmxlib/string2.c
src/gromacs/gmxlib/thread_mpi/impl.h
src/gromacs/gmxlib/thread_mpi/p2p_buffer.c
src/gromacs/gmxlib/thread_mpi/pthreads.c
src/gromacs/legacyheaders/main.h
src/programs/mdrun/runner.c

index f70661b19e96d126966b94181a38ad0096f94572..7d1bbadd8e0d677d3ccefbff657cdffbb151d6dc 100644 (file)
@@ -843,6 +843,16 @@ if (${CMAKE_SYSTEM_NAME} MATCHES "BlueGene")
     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")
index 72b36ff903db75898e189f0f789ef95993e8e195..d6ff665f8e6de213be4028482a681529d18d36ff 100644 (file)
 /* 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
 
index 050a9e1f05d7b0d0c693419893d819fcc49e96b2..391ebe887e703451cfd4cb8a4ffcfaf270d3dba4 100644 (file)
@@ -60,6 +60,11 @@ if(${GMX_CPU_ACCELERATION} MATCHES "^(SSE|AVX)")
     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)
@@ -74,7 +79,8 @@ message(WARNING "The GROMACS build will download FFTW ${EXTERNAL_FFTW_VERSION} a
         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)
index 6cacc9562de309618b5d4457fda0b1372b1c96d7..4d5056676a47dab3e9c90ca85f5364e77e7c7054 100644 (file)
@@ -122,10 +122,7 @@ void push_ps(FILE *fp)
 #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...");
@@ -139,8 +136,8 @@ static int pclose(FILE *fp)
 
     return 0;
 }
-#endif
-#endif
+#endif /* !defined(HAVE_PIPES) && !defined(__native_client__) */
+#endif /* GMX_FAHCORE */
 
 int ffclose(FILE *fp)
 {
index e109fc75ed9d3a2b93760a08ed230e0d1a149826..d148c0357498f17c8c5683e49269a6638cbb2ed8 100644 (file)
@@ -117,6 +117,10 @@ do_trajectory_writing(FILE           *fplog,
         fcReportProgress( ir->nsteps, step );
     }
 
+#if defined(__native_client__)
+    fcCheckin(MASTER(cr));
+#endif
+
     /* sync bCPT and fc record-keeping */
     if (bCPT && MASTER(cr))
     {
index fe195577603cecd3cb4152ca7cfcab1f0962b7e5..5a3fb148b0ab5a77f4811b08a8d6589c31d523e1 100644 (file)
@@ -67,6 +67,7 @@
 #include "network.h"
 #include "gmx_random.h"
 #include "checkpoint.h"
+#include "main.h"
 #include "string2.h"
 #include <fcntl.h>
 
@@ -840,14 +841,7 @@ static void do_cpt_header(XDR *xd, gmx_bool bRead, int *file_version,
     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);
@@ -1434,6 +1428,7 @@ void write_checkpoint(const char *fn, gmx_bool bNumberAndKeep,
         npmenodes = 0;
     }
 
+#ifndef GMX_NO_RENAME
     /* make the new temporary filename */
     snew(fntemp, strlen(fn)+5+STEPSTRSIZE);
     strcpy(fntemp, fn);
@@ -1441,7 +1436,13 @@ void write_checkpoint(const char *fn, gmx_bool bNumberAndKeep,
     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);
 
@@ -1583,6 +1584,7 @@ void write_checkpoint(const char *fn, gmx_bool bNumberAndKeep,
 
     /* 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))
@@ -1611,6 +1613,7 @@ void write_checkpoint(const char *fn, gmx_bool bNumberAndKeep,
             gmx_file("Cannot rename checkpoint file; maybe you are out of disk space?");
         }
     }
+#endif  /* GMX_NO_RENAME */
 
     sfree(outputfiles);
     sfree(fntemp);
@@ -1756,7 +1759,7 @@ static void read_checkpoint(const char *fn, FILE **pfplog,
     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
@@ -1769,7 +1772,7 @@ static void read_checkpoint(const char *fn, FILE **pfplog,
         "      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;
@@ -2064,11 +2067,14 @@ static void read_checkpoint(const char *fn, FILE **pfplog,
                  * 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)
index 33d50dbf3522aab11b532d8913b99c360d6fac94..514757d63fb6df994fbb4c14d3df445de5c6865d 100644 (file)
@@ -609,7 +609,7 @@ static void gmx_print_version_info(FILE *fp)
 #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");
index 26506521f75a226a10687acc9e964cac7bc1d28d..4332d1a70103735ae9b42e9efe86b388c0ab510c 100644 (file)
@@ -564,7 +564,7 @@ static void gmx_detect_gpus(FILE *fplog, const t_commrec *cr)
 
     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)
         {
index 69c0b752cd128cabea53da93b4d71ce30aa7a6b5..4ed60e62120339a3a27e9970a72f61d7f3f631eb 100644 (file)
@@ -222,22 +222,23 @@ void check_multi_int64(FILE *log, const gmx_multisim_t *ms,
 }
 
 
-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;
 }
 
 
index 405111ee9df4eb2243d9e0cd64c7aa75959d0638..f3d79ada1f3aaf3335da15834161c0d7208cf7fa 100644 (file)
@@ -64,6 +64,7 @@
 #include "smalloc.h"
 #include "gmx_fatal.h"
 #include "macros.h"
+#include "main.h"
 #include "string2.h"
 #include "gromacs/fileio/futil.h"
 
@@ -236,7 +237,7 @@ void nice_header (FILE *out, const char *fn)
 #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
index 94d0646302fe21edab3c4b72ead5f47e315da608..962e80c923e1f7659e5856c18cac6659b56aabe3 100644 (file)
@@ -40,6 +40,9 @@
    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>
index dfcd86b86c54c61ac0264992e53ff27a3bd80e58..c2d4c407c193551cd2d06ca9f81009cadfcba3cc 100644 (file)
 
 int MPI_Buffer_attach(void* buffer, int size)
 {
+    return 0;
 }
 
 
 int MPI_Buffer_detach(void* buffer_addr, int* size)
 {
+    return 0;
 }
index 1c62caf0e33ca56fb79619b0d79db8f83b1e4d52..8da1df67514b046c5195364fb602500fa4019dde 100644 (file)
@@ -435,8 +435,8 @@ static inline int tMPI_Thread_mutex_init_once(tMPI_Thread_mutex_t *mtx)
                 goto err;
             }
         }
+        ret = pthread_mutex_unlock( &(mutex_init) );
     }
-    ret = pthread_mutex_unlock( &(mutex_init) );
     return ret;
 err:
     pthread_mutex_unlock( &(mutex_init) );
@@ -765,6 +765,9 @@ void tMPI_Thread_exit(void *value_ptr)
 
 int tMPI_Thread_cancel(tMPI_Thread_t thread)
 {
+    #ifdef __native_client__
+    return ENOSYS;
+    #endif
     return pthread_cancel(thread->th);
 }
 
index 3089e002376d28533416603bbf5494f54da37c10..81011e23f91ea8198acf62cca0aee031829c98cf 100644 (file)
 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,
index a11bd54a4e0a51649d279b0442248b833a37a7c6..ed32d5f0995fbda6da65a30184111fa539b1aa15 100644 (file)
@@ -1312,7 +1312,10 @@ int mdrunner(gmx_hw_opt_t *hw_opt,
     }
 
 #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,