<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=http://email.email.llvm.org/c/eJylVl1vozgU_TXkxWoEBpLwkIc0aaWRZtKRpqt5HBlsgrcOIBuSmf31e65JCJltV1ptRYk_rs8999xrm7yRv9afAr48MtvXta4PTLBOuY6VtjmyrlKsVmfqv7Sq_vKVqZ_i2BrlmGyK_qjqLuBbmInOr3J-RQPTY8tcIWomtVVFp09qztj3StWsaI6tNkqys-6qpu_8iofysqY04jAgqoFGwHkrnFMODXRWBwUn6mcLUGCI2p2VxVxG8AD8GK3UtTDsJEyPdmP92ElYLXKjmAOeLjUQde1nPHddF6Z34H6LgiiAyRn_cAoRoMT-5ZVVAnMa1KZuiqYlyFwUb6xrPO5RuE6Rc6uEBOfXSjuGRxjDqgbxFo1URLmGvbCIlll10E3tYEx5Og26XPTzryDeBOEuCDd_5H3d9awwAmk8QResY1EyD-fhQ8Af8fCQRxHnYZjyVRpiIOZZHkarqIjL6CEKlk-Qln6uhtGSZ-liniWDB1EPfofe5uXL1x_fXjf73ebzy_7pB7l6CN_1T7pVXdc6Isuf8RwA0-dzlAM6VkjV1JQ1Ko--gwTPxpyOD61t_oTyjC8WRZakKk4yEeVKxQu-KEUZF6XMo0WWJJHMU77IkJSB2_D-xCiPADlpqa4lTMmGqqWycIf86ZJJ5ZBhSshnKH5U7K1uzjSBnFmQWSJD9a-uov2hjFNsAJYN5bVSpsXKqd9XKt1CODXm5vLmsS8qkAnireukbubI39MwC5FiqVBBiu1ZFIbTlShGEBO6hpCnRssxUBYsHycmIkgf90G6oxrKr-34amEaBOBf7AwGOxaOcyMFSg6gdKeF0X-JDkm8zNG2gXty8zau9s0t2_vmUGU3bsTmDQy8NQz5I4s-8Dia0oYYNBp341AUngprSsqn7AvKhVWuNx0t8MHS-ntUKNpacTgKBgjWCouNpoyPxOmjBACQfIgUF-16CEchxBt2nmj8Mcy7CGwCwf67epOcUp4IazcKRKbv0ro_s-BqEsAoj_d8nmIsd3fpaC0YltdjLkYhpcbIazmFngANSt-PfuvzWz9It7U_Jrckw2T5pR1N2n4ZyI6FeklfGtIptWURi9nifjsQRQJGPe3IDIFs8Uzc0Ew0HY7G4Xg6zMfhBSMSN-3ZnRrPQhuyu8Y1oYs_q7re1pPyvil7h_KtL3DouA-ALij_3JZXrJlcxzKLMzETPe5Pu7a6qISVuMX0G67mWW_N-l9OWjpVfztc0dXO9XTFPqdxnCSzar3KShWrgoskSsNlHhY8W6yWkUqixWolZT4zIsdBuIZ8CAGfCMxDUDjpbvb_Geg1biBcPzzCbxyv5nwleFJImfB4mSzLIkhChePQzAln3tjDzK49ZN4fHCaNxtfIbRKfEPpQK-UJg2GnO6PWw001fi5g6XCrfnT7zzzLtaf4N0eVsoA>53344</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
clang -fopenmp bug with scan inclusive directive
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
richardbleikamp
</td>
</tr>
</table>
<pre>
I'm running a test from the newest OpenMP examples document, that tests the openmp scan directive. When compiled without the -fopenmp flag, the test "passes" (gets expected answers). With the -fopenmp flag, the final value for the variable specified in the scan inclusive directive ("w") does NOT have its final value copied back to the master thread. This is all host code, no target regions. I've tested with with:
Ubuntu clang version 14.0.0-++20211220052850+329b0181c3f1-1~exp1~20211220172956.94
and with
AOMP_STANDALONE_14.0-0 clang version 14.0.0 (https://github.com/radeonopencompute/llvm-project 266c945e349a1bee3626faf3cfdb169441db5269)
I can provide OpenMP spec references if desired. Let me know if there's anything else I can do to help.
Test case:
#include <stdio.h>
#define N 100
int main(void)
{
int a[N], b[N];
long long w = 0;
// initialization
for (int k = 0; k < N; k++)
a[k] = k + 1;
// a[k] is included in the computation of producing results in b[k]
// #pragma omp parallel for simd reduction(inscan,+: w)
#pragma omp parallel for reduction(inscan, +: w)
for (int k = 0; k < N; k++) {
w += a[k];
#pragma omp scan inclusive(w)
b[k] = w;
}
printf("w=%lld, b[0]=%d b[1]=%d b[2]=%d\n", w, b[0], b[1], b[2]);
// 5050, 1 3 6
if( w!=5050 || b[0]!=1 || b[1]!=3 || b[2]!=6 ){
printf("Fail!\n");
return 1;
}
printf("Success!\n");
return 0;
}
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyVVl2PmzgU_TXkxZoIDITwkIdMMiNVajOVOqt9rAw2iTsOIBuStr9-zzUJId2ZlXbEEH9cn3vuudc2RSN_rT4FPDsy29e1rvdMsE65jlW2ObLuoFitztR_aVX95StTP8WxNcox2ZT9UdVdwDcwE51f5fyKBqbHlrlS1Exqq8pOn9Scsb8PqmZlc2y1UZKddXdo-s6veKguayoj9gOiGmgEnLfCOeXQQGe5V3CifrYABYao3VlZzOUED8CP0SpdC8NOwvRoN9aPnYTVojCKOeDpSgNR137Gc9d1aXoH7rcoiAKYnPEPpxABSuxeXtlBYE6D2tRN2bQEWYjyjXWNxz0K1ylybpWQ4Px60I7hEcawQ4N4y0YqolzDXlhEy6za66Z2MKY8nQZdLvr5VxCvg3AbhOu_ir7uelYagTSeoAvWsSiZh_PwIeCPeHjIo4jzMEz5Mg0xEPO8CKNlVMZV9BAF2ROkpZ-rYZTxPF3M82TwIOrB79Bbv3z5-v3b63q3XX9-2T19J1cP4bv-SbdD17WOyPJnPHvA9MUc5YCOFVI1NWWNyqPvIMGzMafjQ2ubH1Ce8cWizJNUxUkuokKpeMEXlajispJFtMiTJJJFyhc5kjJwG96fGOURICct1bWEKdlQtVIW7pA_XTGpHDJMCfkMxY-KvdXNmSaQMwsyGTJU_-oOtD-UcYoNwLKhvB6UabFy6veVSrcUTo25ubx57IsKZIJ44zqpmzny9zTMQqRYKlSQYjsWheF0JYoRxISuIeSp0XIMlAXZ48REBOnjLki3VEPFtR1fLUyDAPyLncFgy8JxbqRAyQGU7rQw-rfokMTLHG0buCc3b-Nq39ywnW8OVXbjRmzewMBbw5A_sugDj6MpbYhBo3E3D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