More precise analysisdata histogram accumulation
[alexxy/gromacs.git] / src / gromacs / analysisdata / datastorage.h
index f2043e2f9beb3d3c880c73f184890922f50b7671..4e9fd2534127aa686175851136d49766b7d737a7 100644 (file)
@@ -1,10 +1,10 @@
 /*
  * This file is part of the GROMACS molecular simulation package.
  *
- * Copyright (c) 2012,2013, by the GROMACS development team, led by
- * David van der Spoel, Berk Hess, Erik Lindahl, and including many
- * others, as listed in the AUTHORS file in the top-level source
- * directory and at http://www.gromacs.org.
+ * Copyright (c) 2012,2013,2014, by the GROMACS development team, led by
+ * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
+ * and including many others, as listed in the AUTHORS file in the
+ * top-level source directory and at http://www.gromacs.org.
  *
  * GROMACS is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public License
 
 #include <vector>
 
-#include "../legacyheaders/types/simple.h"
-
-#include "../utility/common.h"
-#include "../utility/gmxassert.h"
-
-#include "dataframe.h"
+#include "gromacs/analysisdata/dataframe.h"
+#include "gromacs/utility/common.h"
+#include "gromacs/utility/gmxassert.h"
+#include "gromacs/utility/real.h"
 
 namespace gmx
 {
@@ -189,8 +187,9 @@ class AnalysisDataStorageFrame
          *
          * After this method has been called, all values appear as not set.
          *
-         * May call AnalysisDataModuleManager::notifyPointsAdd(), and may throw
-         * any exception this method throws.
+         * May call AnalysisDataModuleManager::notifyPointsAdd() and
+         * AnalysisDataModuleManager::notifyParallelPointsAdd(), and may throw
+         * any exception these methods throw.
          */
         void finishPointSet();
         /*! \brief
@@ -249,7 +248,8 @@ class AnalysisDataStorageFrame
  * To use this class in a class derived from AbstractAnalysisData, a member
  * variable of this type should be declared and the pure virtual methods
  * forwarded to frameCount(), tryGetDataFrame() and requestStorage().
- * Storage properties should be set up, and then startDataStorage() called.
+ * Storage properties should be set up, and then startDataStorage() or
+ * startParallelDataStorage() called.
  * New frames can then be added using startFrame(), currentFrame() and
  * finishFrame() methods.  When all frames are ready, finishDataStorage() must
  * be called.  These methods (and AnalysisDataStorageFrame::finishPointSet())
@@ -269,18 +269,6 @@ class AnalysisDataStorage
         AnalysisDataStorage();
         ~AnalysisDataStorage();
 
-        /*! \brief
-         * Set parallelization options for the storage.
-         *
-         * \param[in] opt  Parallization options to use.
-         *
-         * If this method is not called, the storage is set up for serial
-         * storage only.
-         *
-         * Does not throw.
-         */
-        void setParallelOptions(const AnalysisDataParallelOptions &opt);
-
         /*! \brief
          * Returns the number of ready frames.
          *
@@ -341,6 +329,27 @@ class AnalysisDataStorage
          */
         void startDataStorage(AbstractAnalysisData      *data,
                               AnalysisDataModuleManager *modules);
+        /*! \brief
+         * Start storing data in parallel.
+         *
+         * \param[in] data    AbstractAnalysisData object containing this
+         *      storage.
+         * \param[in] options Parallelization options to use.
+         * \param     modules Module manager for \p data.
+         * \exception std::bad_alloc if storage allocation fails.
+         *
+         * Should be called instead of startDataStorage() if the data will be
+         * produced in parallel.  Works as startDataStorage(), but additionally
+         * initializes the storage and the attached modules to prepare for
+         * out-of-order data frames.
+         *
+         * Calls AnalysisDataModuleManager::notifyParallelDataStart(), and
+         * throws any exceptions this method throws.
+         */
+        void startParallelDataStorage(
+            AbstractAnalysisData              *data,
+            AnalysisDataModuleManager         *modules,
+            const AnalysisDataParallelOptions &options);
         /*! \brief
          * Starts storing a new frame.
          *
@@ -359,13 +368,14 @@ class AnalysisDataStorage
          * far in the future:
          * If \c i is the index of the last frame such that all frames from
          * 0, ..., \c i have been finished, then \p header().index() should be
-         * at most \c 2*parallelizationFactor-1 larger than \c i, where
+         * at most \c parallelizationFactor larger than \c i, where
          * parallelizationFactor is the parallelization factor passed to
          * setParallelOptions().
          * Throws APIError if this constraint is violated.
          *
-         * Calls AnalysisDataModuleManager::notifyFrameStart() in certain
-         * cases, and throws any exceptions this method throws.
+         * Calls AnalysisDataModuleManager::notifyFrameStart() (in certain
+         * cases) and AnalysisDataModuleManager::notifyParallelFrameStart(),
+         * and throws any exceptions these methods throw.
          */
         AnalysisDataStorageFrame &startFrame(const AnalysisDataFrameHeader &header);
         /*! \brief