This is an archive of the discontinued LLVM Phabricator instance.

[Polly] Refactoring astScheduleDimIsParallel to take the C++ wrapper object. NFC
ClosedPublic

Authored by QwertycowMoo on Mar 11 2021, 2:28 PM.

Details

Summary

Polly currently needs to be slowly refactor to use the C++ wrapper objects to handle the reference counters automatically.
I took the function of astScheduleDimIsParallel and refactored it so that it uses the C++ wrapper function as much as possible.

There are some problems with the IsParallel since it expects the C objects, so the C++ wrapper functions must be .release() and .get() first before they are able to be used with IsParallel.

When checking the ReductionDependencies Parallelism with the Build's Schedule, I opted to keep the union map as a C object rather than a C++ object. Eventually, changes will need to be made to IsParallel to refactor it to the C++ wrappers. When this is done, this function will also need to be slightly refactored to not use the C object.

Diff Detail

Event Timeline

QwertycowMoo created this revision.Mar 11 2021, 2:28 PM
QwertycowMoo requested review of this revision.Mar 11 2021, 2:28 PM
Herald added a project: Restricted Project. · View Herald TranscriptMar 11 2021, 2:28 PM
Meinersbur added inline comments.Mar 11 2021, 3:04 PM
polly/lib/CodeGen/IslAst.cpp
209

[nit] unrelated whitespace change

222

Could you mark such line with an "TODO"?

// TODO: We will need to change isParallel to stop the unwrapping.
223–224

MinimalDependenceDistance contains nullptr at this point, not necessary to wrap it. Which basically means without changing isParallel, there is nothing to do here.

233–235
243–245

I used RedDeps2 in my examples, but its not a good variable name.

When checking the ReductionDependencies Parallelism with the Build's Schedule, I opted to keep the union map as a C object rather than a C++ object. Eventually, changes will need to be made to IsParallel to refactor it to the C++ wrappers. When this is done, this function will also need to be slightly refactored to not use the C object.

[suggestion] Consider

isl::union_map MaRedDeps = isl::manage_copy(MaRedPair.second);
if (!D->isParallel(Schedule.get(), MaRedDeps.release()))

I think it still looks better even without converting IsParallel as well.

Edited whitespace and style conventions. Asked a question about the implicit conversion of isl::map to isl::union_map but still changed it.

Meinersbur accepted this revision.Mar 12 2021, 10:39 PM

LGTM, thanks for the adjustments.

Would you me to push it to main?

This revision is now accepted and ready to land.Mar 12 2021, 10:39 PM

Yup! Please push for me I'm not sure whether I should be doing that yet so if you @Meinersbur could push it that would be great!

polly/lib/CodeGen/IslAst.cpp
243–245

Does this mean that we can have implicit conversion from isl::map to isl::union_map?
It seems that MaRedPair.second is an isl_map and when we apply isl::manage_copy we get an isl::map.
Can we implicitly convert that to isl::union_map?

Meinersbur added inline comments.Mar 15 2021, 6:21 AM
polly/lib/CodeGen/IslAst.cpp
243–245

Yes, this is what my suggested code is doing. Written with every conversion on its own line:

isl::map MaRedDeps1 = isl::manage_copy(MaRedPair.second);
isl::union_map MaRedDeps2 = MaRedDeps1; // implicit conversion
isl_union_map *MaRedDeps3 = MaRedDeps.release();
if (!D->isParallel(Schedule.get(), MaRedDeps3)

On a single line:

if (!D->isParallel(Schedule.get(), isl::union_map(isl::manage_copy(MaRedPair.second)).release())

where the conversion is not that implicit anymore.