Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
BornAgain
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
mlz
BornAgain
Commits
0635738f
Commit
0635738f
authored
7 years ago
by
Van Herck, Walter
Browse files
Options
Downloads
Patches
Plain Diff
Move batch processing up to Simulation::runSimulation
parent
05659a3b
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
Core/Simulation/Simulation.cpp
+14
-13
14 additions, 13 deletions
Core/Simulation/Simulation.cpp
Core/Simulation/Simulation.h
+2
-1
2 additions, 1 deletion
Core/Simulation/Simulation.h
with
16 additions
and
14 deletions
Core/Simulation/Simulation.cpp
+
14
−
13
View file @
0635738f
...
...
@@ -131,17 +131,27 @@ void Simulation::runSimulation()
+
(
sample
()
->
hasRoughness
()
?
1
:
0
);
m_progress
.
setExpectedNTicks
(
prefactor
*
param_combinations
*
numberOfSimulationElements
());
// restrict calculation to current batch
const
size_t
n_batches
=
m_options
.
getNumberOfBatches
();
const
size_t
current_batch
=
m_options
.
getCurrentBatch
();
const
size_t
total_size
=
numberOfSimulationElements
();
const
size_t
batch_start
=
getStartIndex
(
n_batches
,
current_batch
,
total_size
);
const
size_t
batch_size
=
getNumberOfElements
(
n_batches
,
current_batch
,
total_size
);
if
(
batch_size
==
0
)
return
;
std
::
unique_ptr
<
ParameterPool
>
P_param_pool
(
createParameterTree
());
if
(
param_combinations
==
1
)
{
// no averaging needed:
m_distribution_handler
.
setParameterValues
(
P_param_pool
.
get
(),
0
);
runSingleSimulation
();
runSingleSimulation
(
batch_start
,
batch_size
);
}
else
{
// average over parameter distributions:
const
bool
use_storage
=
true
;
for
(
size_t
index
=
0
;
index
<
param_combinations
;
++
index
)
{
double
weight
=
m_distribution_handler
.
setParameterValues
(
P_param_pool
.
get
(),
index
);
runSingleSimulation
(
use_storage
,
weight
);
runSingleSimulation
(
batch_start
,
batch_size
,
use_storage
,
weight
);
}
moveDataFromStorage
();
}
...
...
@@ -214,21 +224,12 @@ void Simulation::updateSample()
//! Runs a single simulation with fixed parameter values.
//! If desired, the simulation is run in several threads.
void
Simulation
::
runSingleSimulation
(
bool
use_storage
,
double
weight
)
void
Simulation
::
runSingleSimulation
(
size_t
batch_start
,
size_t
batch_size
,
bool
use_storage
,
double
weight
)
{
prepareSimulation
();
initSimulationElementVector
(
use_storage
&&
!
isStorageInited
());
// restrict calculation to current batch
const
size_t
n_batches
=
m_options
.
getNumberOfBatches
();
const
size_t
current_batch
=
m_options
.
getCurrentBatch
();
const
size_t
total_size
=
numberOfSimulationElements
();
const
size_t
batch_start
=
getStartIndex
(
n_batches
,
current_batch
,
total_size
);
const
size_t
batch_size
=
getNumberOfElements
(
n_batches
,
current_batch
,
total_size
);
if
(
batch_size
==
0
)
return
;
const
size_t
n_threads
=
m_options
.
getNumberOfThreads
();
assert
(
n_threads
>
0
);
...
...
This diff is collapsed.
Click to expand it.
Core/Simulation/Simulation.h
+
2
−
1
View file @
0635738f
...
...
@@ -116,7 +116,8 @@ private:
//! Update the sample by calling the sample builder, if present
void
updateSample
();
void
runSingleSimulation
(
bool
use_storage
=
false
,
double
weight
=
1.0
);
void
runSingleSimulation
(
size_t
batch_start
,
size_t
batch_size
,
bool
use_storage
=
false
,
double
weight
=
1.0
);
//! Initializes the vector of Simulation elements
//! @param init_storage Initialize storage for accumulating results
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment