<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body text="#000000" bgcolor="#FFFFFF">
<p><tt>Hi,</tt></p>
<tt> </tt>
<p><tt>I did some little research and I have realized that the patch
I attached doesn't fix the problem completely. I fixed the
storage of the data. When a using task reduction with vla, or a
class that uses omp_orig to initialize the private copies, the
size of the vla and omp_orig are stored in a storage using
__kmpc_threadprivate_cached().</tt></p>
<tt> </tt>
<p><tt>The problem comes because, since in outline parallel function
each reduction has lazy_priv flag, the initialization will be
done in __kmpc_task_reduction_get_th_data(), called from outline
task function. This is done </tt><tt><u>before</u></tt><tt>
storing the vla size or omp_orig, so the initialization would be
wrong in these cases.</tt></p>
<tt> </tt>
<p><tt>I think that if the storage is put before the
__kmpc_task_reduction_get_th_data() it should work.</tt></p>
<tt> </tt>
<p><tt>Anyway, this implementation of task reductions is not fully
functional, as only are allowed if the task is created in the
scope of taskgroup.</tt><tt><br>
</tt></p>
<p><tt>Sorry for the mail duplicate.<br>
</tt> </p>
<tt> </tt>
<p><tt>Regards,</tt></p>
<tt> Raúl</tt><tt><br>
</tt><tt><br>
</tt>
<div class="moz-cite-prefix"><tt>El 06/03/18 a las 16:21, Alexey
Bataev escribió:</tt><tt><br>
</tt></div>
<blockquote type="cite"
cite="mid:AM5PR0902MB192332923553F3139032AB6385D90@AM5PR0902MB1923.eurprd09.prod.outlook.com">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<p><tt>Hi, thanks for the report, I'll take a look.</tt><tt><br>
</tt> </p>
<pre class="moz-signature" cols="72">-------------
Best regards,
Alexey Bataev</pre>
<div class="moz-cite-prefix"><tt>06.03.2018 4:25, Raúl Peñacoba
via cfe-dev пишет:</tt><tt><br>
</tt> </div>
<blockquote type="cite"
cite="mid:%3C8c87489c-07b9-25bc-0b3b-66d9d295bf8f@bsc.es%3E"><tt>Hi,
</tt><tt><br>
</tt> <tt><br>
</tt><tt> I've noticed that clang does not work properly when
using task reductions with non-constant arrays and/or classes
with omp_orig constructor initializers. </tt><tt><br>
</tt> <tt><br>
</tt><tt> As reduction initialize/combine/finalize functions
only receive references to whatever should be initialized,
combined..., clang generates some additional storages to save
the size of the reduction array and a pointer to the omp_orig.
That storages are generated through
__kmpc_thread_private_cached() calls in both reduction
functions and outline task function. </tt><tt><br>
</tt> <tt><br>
</tt><tt> The problem is that the storage used in outline task
function does not match the storage in reduction functions.
This happens in programs that have a task reduction or a
taskloop reduction with the in_reduction clause. </tt><tt><br>
</tt> <tt><br>
</tt><tt> To solve this i made an ugly patch that reuses the
SourceLocation of CodeGenFunction::EmitOMPTaskgroupDirective()
in CodeGenFunction::EmitOMPTaskBasedDirective() to match the
storages and make it work. Anyway, i suppose that there is a
better way to fix this. </tt><tt><br>
</tt> <tt><br>
</tt><tt> Index: CGStmtOpenMP.cpp </tt><tt><br>
</tt><tt>
=================================================================== </tt><tt><br>
</tt><tt> --- CGStmtOpenMP.cpp (revision 326685) </tt><tt><br>
</tt><tt> +++ CGStmtOpenMP.cpp (working copy) </tt><tt><br>
</tt><tt> @@ -2713,6 +2713,8 @@ </tt><tt><br>
</tt><tt>
emitEmptyBoundParameters); </tt><tt><br>
</tt><tt> } </tt><tt><br>
</tt> <tt><br>
</tt><tt> +static SourceLocation reductionLoc; </tt><tt><br>
</tt><tt> + </tt><tt><br>
</tt><tt> void CodeGenFunction::EmitOMPTaskBasedDirective( </tt><tt><br>
</tt><tt> const OMPExecutableDirective &S, const
OpenMPDirectiveKind CapturedRegion, </tt><tt><br>
</tt><tt> const RegionCodeGenTy &BodyGen, const
TaskGenTy &TaskGen, </tt><tt><br>
</tt><tt> @@ -2952,7 +2954,7 @@ </tt><tt><br>
</tt><tt> // FIXME: This must removed once the runtime
library is fixed. </tt><tt><br>
</tt><tt> // Emit required threadprivate variables for
</tt><tt><br>
</tt><tt> // initilizer/combiner/finalizer. </tt><tt><br>
</tt><tt> -
CGF.CGM.getOpenMPRuntime().emitTaskReductionFixups(CGF,
S.getLocStart(), </tt><tt><br>
</tt><tt> +
CGF.CGM.getOpenMPRuntime().emitTaskReductionFixups(CGF,
reductionLoc, </tt><tt><br>
</tt><tt> RedCG, Cnt); </tt><tt><br>
</tt><tt> } </tt><tt><br>
</tt><tt> } </tt><tt><br>
</tt><tt> @@ -3180,8 +3182,9 @@ </tt><tt><br>
</tt><tt> std::advance(IRHS, 1); </tt><tt><br>
</tt><tt> } </tt><tt><br>
</tt><tt> } </tt><tt><br>
</tt><tt> + reductionLoc = S.getLocStart(); </tt><tt><br>
</tt><tt> llvm::Value *ReductionDesc = </tt><tt><br>
</tt><tt> -
CGF.CGM.getOpenMPRuntime().emitTaskReductionInit(CGF,
S.getLocStart(), </tt><tt><br>
</tt><tt> +
CGF.CGM.getOpenMPRuntime().emitTaskReductionInit(CGF,
reductionLoc, </tt><tt><br>
</tt><tt> LHSs, RHSs, Data); </tt><tt><br>
</tt><tt> const auto *VD =
cast<VarDecl>(cast<DeclRefExpr>(E)->getDecl());
</tt><tt><br>
</tt><tt> CGF.EmitVarDecl(*VD); </tt><tt><br>
</tt> <tt><br>
</tt><tt> Regards, </tt><tt><br>
</tt> <tt><br>
</tt><tt> Raúl </tt><tt><br>
</tt> <tt><br>
</tt> <tt><br>
</tt> <tt><a class="moz-txt-link-freetext"
href="http://bsc.es/disclaimer" moz-do-not-send="true">http://bsc.es/disclaimer</a></tt><tt>
</tt><tt><br>
</tt> <tt><br>
</tt> </blockquote>
<tt><br>
</tt> </blockquote>
<tt><br>
</tt>
<br>
<br>
WARNING / LEGAL TEXT: This message is intended only for the use of the
individual or entity to which it is addressed and may contain
information which is privileged, confidential, proprietary, or exempt
from disclosure under applicable law. If you are not the intended
recipient or the person responsible for delivering the message to the
intended recipient, you are strictly prohibited from disclosing,
distributing, copying, or in any way using this message. If you have
received this communication in error, please notify the sender and
destroy and delete any copies you may have received.
<br><br>
<a href="http://www.bsc.es/disclaimer">http://www.bsc.es/disclaimer</a>
<br>
</body>
</html>