Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
R
Root
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
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
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
Keyboard shortcuts
?
Snippets
Groups
Projects
Admin message
为了安全,强烈建议开启2FA双因子认证:User Settings -> Account -> Enable two-factor authentication!!!
Show more breadcrumbs
cxwx
Root
Commits
dcfc7601
Commit
dcfc7601
authored
6 years ago
by
Enrico Guiraud
Committed by
Danilo Piparo
6 years ago
Browse files
Options
Downloads
Patches
Plain Diff
[DF] Add test for Define+nested parallelism
parent
cc0b8b19
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
tree/dataframe/test/CMakeLists.txt
+4
-0
4 additions, 0 deletions
tree/dataframe/test/CMakeLists.txt
tree/dataframe/test/dataframe_concurrency.cxx
+44
-0
44 additions, 0 deletions
tree/dataframe/test/dataframe_concurrency.cxx
with
48 additions
and
0 deletions
tree/dataframe/test/CMakeLists.txt
+
4
−
0
View file @
dcfc7601
...
@@ -18,6 +18,10 @@ ROOT_ADD_GTEST(dataframe_leaves dataframe_leaves.cxx LIBRARIES ROOTDataFrame)
...
@@ -18,6 +18,10 @@ ROOT_ADD_GTEST(dataframe_leaves dataframe_leaves.cxx LIBRARIES ROOTDataFrame)
ROOT_ADD_GTEST
(
dataframe_vecops dataframe_vecops.cxx LIBRARIES ROOTDataFrame
)
ROOT_ADD_GTEST
(
dataframe_vecops dataframe_vecops.cxx LIBRARIES ROOTDataFrame
)
ROOT_ADD_GTEST
(
dataframe_resptr dataframe_resptr.cxx LIBRARIES ROOTDataFrame
)
ROOT_ADD_GTEST
(
dataframe_resptr dataframe_resptr.cxx LIBRARIES ROOTDataFrame
)
if
(
imt
)
ROOT_ADD_GTEST
(
dataframe_concurrency dataframe_concurrency.cxx LIBRARIES ROOTDataFrame
)
endif
()
ROOT_ADD_GTEST
(
datasource_more datasource_more.cxx LIBRARIES ROOTDataFrame
)
ROOT_ADD_GTEST
(
datasource_more datasource_more.cxx LIBRARIES ROOTDataFrame
)
#ROOT_ADD_GTEST(datasource_root datasource_root.cxx LIBRARIES ROOTDataFrame)
#ROOT_ADD_GTEST(datasource_root datasource_root.cxx LIBRARIES ROOTDataFrame)
ROOT_ADD_GTEST
(
datasource_trivial datasource_trivial.cxx LIBRARIES ROOTDataFrame
)
ROOT_ADD_GTEST
(
datasource_trivial datasource_trivial.cxx LIBRARIES ROOTDataFrame
)
...
...
This diff is collapsed.
Click to expand it.
tree/dataframe/test/dataframe_concurrency.cxx
0 → 100644
+
44
−
0
View file @
dcfc7601
#include
<ROOT/RDataFrame.hxx>
#include
<ROOT/TThreadExecutor.hxx>
#include
<atomic>
#include
<chrono>
#include
<thread>
#include
"gtest/gtest.h"
#ifdef R__USE_IMT
TEST
(
RDFConcurrency
,
NestedParallelismBetweenDefineCalls
)
{
ROOT
::
EnableImplicitMT
();
// this Define will return unique values from 0 to nEntries - 1 (over all threads)
const
auto
nEntries
=
100000u
;
std
::
atomic_int
i
(
0
);
auto
df
=
ROOT
::
RDataFrame
(
nEntries
).
Define
(
"i"
,
[
&
]
{
return
i
++
;
});
// this lambda will be used to introduce nested parallelism via a dummy Filter
auto
manysleeps
=
[
&
]
{
ROOT
::
TThreadExecutor
().
Foreach
(
[]
{
std
::
this_thread
::
sleep_for
(
std
::
chrono
::
milliseconds
(
std
::
rand
()
/
RAND_MAX
*
200
));
},
8
);
return
true
;
};
// first Take triggers the computation of i, then the Filter executes, then Take accesses the cached value of i
// hopefully it won't have changed in the meanwhile!
auto
res1
=
df
.
Take
<
int
>
(
"i"
);
auto
res2
=
df
.
Filter
(
manysleeps
).
Take
<
int
>
(
"i"
);
// check both Takes return vectors with all numbers from 0 to nEntries - 1
auto
checkAllNumbersAreThere
=
[](
std
::
vector
<
int
>
&
vec
)
{
std
::
sort
(
vec
.
begin
(),
vec
.
end
());
const
int
s
=
vec
.
size
();
for
(
auto
i
=
0
;
i
<
s
;
++
i
)
EXPECT_EQ
(
vec
[
i
],
i
);
};
checkAllNumbersAreThere
(
*
res1
);
checkAllNumbersAreThere
(
*
res2
);
ROOT
::
DisableImplicitMT
();
}
#endif
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