[PATCH] D18110: [OpenMP] Fix SEMA bug in the capture of global variables in template functions.
Alexey Bataev via cfe-commits
cfe-commits at lists.llvm.org
Tue Apr 5 01:47:00 PDT 2016
I don't agree with your analysis.
1. This is how it works now. It does not say that the argument must be
passed by value. Later we may add some generic optimization to optimize
not only target specific code, but also non-target specific code.
2. In this case such constructs must be gathered in an implicit
OMPFirstprivateClause to be handled automatically by the existing codegen.
3. It just means this is variable must be gathered in an implicit
OMPPrivateClause and handled by automatic codegen procedure.
Again, I think you must start with basic implementation. I think if we
will start from the basic implementation, some problems may be solved
without any preliminary optimizations.
That's why I insist on non-optimized version of the code as the first step.
Intel Compiler Team
04.04.2016 18:35, Carlo Bertolli пишет:
> carlo.bertolli added a comment.
> Hi Alexey
> I understand your concerns and share the danger of working on optimizations before a correct implementation is actually in place.
> I do not think this is the case. My comment was very precise about the cause-effect: the OpenMP specification was defined in a certain way, and that is what we should implement, and the consequence of that is an optimized implementation compared to what we had in OpenMP 4.0.
> Here are the passages of the OpenMP specifications where I think this is specified (from OpenMP 4.5 specification text):
> - Page 197, description of firstprivate: "A list item that appears in a firstprivate clause is subject to the private clause semantics described in Section 18.104.22.168 on page 192, except as noted. In addition,** the new list item is initialized from the original list item existing before the construct**."
> - Page 105, restrictions of target: "If an array section is a list item in a map clause and the array section is derived from a variable for which the type is pointer then the data-sharing attribute for that variable in the construct is firstprivate. Prior to the execution of the construct, **the private variable is initialized with the address of the storage location of the corresponding array section in the device data environment**."
> - Page 105, following paragraph: "If a zero-length array section is a list item in a map clause, and the array section is derived from a variable for the which the type is pointer then** that variable is initialized with the address of the corresponding storage location in the device data environment**."
> In this I read that whenever we have a map with an array section, or a map on a zero-length array section, or a firstprivate on any kind of variable, we need to copy the value of the variable (scalar, pointer) into the corresponding private variable.
> Implementing this with references would work indeed, but it would be like implementing pass-by-value using references.
> We had long discussion about this with various members of the OpenMP committee on how to implement this correctly. This is why I am insisting on this not being an optimization.
> However, this may not apply here (that is why I conditioned by previous comment) or you still think that we should always pass references for any kind of argument to target regions. It is your call, but I wanted to make sure that this is put in the right light.
> - Carlo
More information about the cfe-commits