Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
mantid
Manage
Activity
Members
Labels
Plan
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Releases
Model registry
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Code review analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
mantidproject
mantid
Commits
ad499f29
Commit
ad499f29
authored
9 years ago
by
Owen Arnold
Browse files
Options
Downloads
Patches
Plain Diff
refs #13517. Parallel algorithm.
parent
22c97ce8
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
Code/Mantid/Framework/MDAlgorithms/src/TransposeMD.cpp
+29
-10
29 additions, 10 deletions
Code/Mantid/Framework/MDAlgorithms/src/TransposeMD.cpp
with
29 additions
and
10 deletions
Code/Mantid/Framework/MDAlgorithms/src/TransposeMD.cpp
+
29
−
10
View file @
ad499f29
#include
"MantidMDAlgorithms/TransposeMD.h"
#include
"MantidKernel/ArrayProperty.h"
#include
"MantidKernel/ArrayBoundedValidator.h"
#include
"MantidKernel/MultiThreaded.h"
#include
"MantidAPI/FrameworkManager.h"
#include
"MantidAPI/IMDHistoWorkspace.h"
#include
"MantidAPI/IMDIterator.h"
#include
"MantidAPI/Progress.h"
#include
"MantidDataObjects/CoordTransformAligned.h"
#include
"MantidDataObjects/MDHistoWorkspace.h"
#include
"MantidGeometry/MDGeometry/IMDDimension.h"
...
...
@@ -11,6 +14,7 @@
#include
<vector>
#include
<algorithm>
#include
<numeric>
#include
<memory>
#include
<boost/shared_ptr.hpp>
#include
<boost/make_shared.hpp>
...
...
@@ -105,7 +109,6 @@ void TransposeMD::exec() {
std
::
iota
(
axes
.
begin
(),
axes
.
end
(),
0
);
}
std
::
vector
<
coord_t
>
origin
(
nDimsOutput
,
0.0
);
std
::
vector
<
Geometry
::
IMDDimension_sptr
>
targetGeometry
;
for
(
size_t
i
=
0
;
i
<
nDimsOutput
;
++
i
)
{
...
...
@@ -123,25 +126,41 @@ void TransposeMD::exec() {
CoordTransformAligned
coordTransform
(
nDimsInput
,
nDimsOutput
,
axes
,
origin
,
scaling
);
IMDIterator
*
inIterator
=
inWS
->
createIterator
();
do
{
uint64_t
nPoints
=
inWS
->
getNPoints
();
Progress
progress
(
this
,
0
,
1
,
size_t
(
nPoints
));
progress
.
reportIncrement
(
size_t
(
double
(
nPoints
)
*
0.1
));
// Report ~10% progress
const
int
nThreads
=
Mantid
::
API
::
FrameworkManager
::
Instance
()
.
getNumOMPThreads
();
// NThreads to Request
auto
iterators
=
inWS
->
createIterators
(
nThreads
,
NULL
);
PARALLEL_FOR_NO_WSP_CHECK
()
for
(
int
it
=
0
;
it
<
int
(
iterators
.
size
());
++
it
)
{
PARALLEL_START_INTERUPT_REGION
auto
inIterator
=
std
::
unique_ptr
<
IMDIterator
>
(
iterators
[
it
]);
do
{
auto
center
=
inIterator
->
getCenter
();
const
coord_t
*
incoords
=
center
.
getBareArray
();
const
coord_t
*
incoords
=
center
.
getBareArray
();
std
::
vector
<
coord_t
>
outcoords
(
nDimsOutput
);
coordTransform
.
apply
(
incoords
,
&
outcoords
[
0
]);
size_t
index
=
outWS
->
getLinearIndexAtCoord
(
&
outcoords
[
0
]);
outWS
->
setSignalAt
(
index
,
inIterator
->
getSignal
());
const
double
error
=
inIterator
->
getError
();
outWS
->
setErrorSquaredAt
(
index
,
error
*
error
);
outWS
->
setErrorSquaredAt
(
index
,
error
*
error
);
outWS
->
setNumEventsAt
(
index
,
inIterator
->
getNumEvents
());
outWS
->
setMDMaskAt
(
index
,
inIterator
->
getIsMasked
());
progress
.
report
();
}
while
(
inIterator
->
next
());
PARALLEL_END_INTERUPT_REGION
}
PARALLEL_CHECK_INTERUPT_REGION
}
while
(
inIterator
->
next
());
this
->
setProperty
(
"OutputWorkspace"
,
outWS
);
this
->
setProperty
(
"OutputWorkspace"
,
outWS
);
}
}
// namespace MDAlgorithms
...
...
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