Skip to content

[DF] Fix compilation of Foreach with mutable lambdas #8318

Merged
eguiraud merged 2 commits intoroot-project:masterfrom
eguiraud:fix_mutable_foreach
Jun 3, 2021
Merged

[DF] Fix compilation of Foreach with mutable lambdas #8318
eguiraud merged 2 commits intoroot-project:masterfrom
eguiraud:fix_mutable_foreach

Conversation

@eguiraud
Copy link
Copy Markdown
Contributor

@eguiraud eguiraud commented Jun 2, 2021

This fixes #8317.

@eguiraud eguiraud requested a review from Axel-Naumann June 2, 2021 09:09
@eguiraud eguiraud self-assigned this Jun 2, 2021
TEST(RDataFrameInterface, MutableForeach)
{
int i = 0;
ROOT::RDataFrame(10).Foreach([&](ULong64_t) mutable { ++i; }, {"rdfentry_"});
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't this rely on IMT being off? Maybe better use atomic_int i?

Copy link
Copy Markdown
Member

@Axel-Naumann Axel-Naumann left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But see comment. I'd really like to tun on IMT by default on Windows and macOS and with X11 outside the grid and batch systems, and this might trigger failures?

@phsft-bot
Copy link
Copy Markdown

Starting build on ROOT-debian10-i386/cxx14, ROOT-performance-centos8-multicore/default, ROOT-ubuntu16/nortcxxmod, mac1014/python3, mac11.0/cxx17, windows10/cxx14
How to customize builds

@eguiraud
Copy link
Copy Markdown
Contributor Author

eguiraud commented Jun 2, 2021

and this might trigger failures?

yes, and not just here. i don't know how much of our code (and users') relies on the default being single-thread execution, but it's probably a fair amount. having to always think about thread-safety even when doing these sort of quick debugging printouts is not a 100% transparent change.

@Axel-Naumann
Copy link
Copy Markdown
Member

And for this test you can be certain that no other code in the same test binary turns on IMT?

@eguiraud
Copy link
Copy Markdown
Contributor Author

eguiraud commented Jun 2, 2021

Yes, the only place that turns on (and then off) IMT in this executable is

#ifdef R__USE_IMT
unsigned int nslots = std::min(3U, std::thread::hardware_concurrency());
ROOT::EnableImplicitMT(nslots);
ROOT::RDataFrame df3(1);
EXPECT_EQ(nslots, df3.GetNSlots());
ROOT::DisableImplicitMT();
ROOT::RDataFrame df1(1);
EXPECT_EQ(1U, df1.GetNSlots());
#endif

@eguiraud
Copy link
Copy Markdown
Contributor Author

eguiraud commented Jun 3, 2021

Merging this. If we want code to be able to never assume implicit MT is off we need a big pass over most RDF code anyway.

@eguiraud eguiraud merged commit 6832151 into root-project:master Jun 3, 2021
@eguiraud eguiraud deleted the fix_mutable_foreach branch June 3, 2021 16:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[DF] Compilation failure when a mutable lambda is passed to Foreach

3 participants