[ADOL-C] OpenMP within an active section
Kshitij Kulshreshtha
kshitij at math.uni-paderborn.de
Thu Mar 30 04:10:15 EDT 2017
Hello Chris,
In order to use OpenMP as it is currently implemented in ADOL-C your
parallel section must contain the whole of tracing and the subsequent
derivative evaluation. Otherwise some of the internal data structures
required get lost. The driver functions like jacobian and gradient
currently assume that they are within some parallel section, and unable
to start one on their own.
Best wishes
Kshitij Kulshreshtha
On 03/27/17 20:57, Chris Dembia wrote:
> Hey all:
>
> I would like to use OpenMP with ADOL-C. I have looked at the OpenMP examples in the ADOL-C source code,
> and I have read the relevant section of the manual. However, I would like to use OpenMP *within* the active
> section, not surrounding the active section. For example:
>
>
> ------
>
> int N = 5;
> short int tag = 0;
> trace_on(tag);
>
> double* px = new double[N];
> for (int i = 0; i < N; ++i) px[i] = 1.5;
> adouble* x = new adouble[N];
> double* py = new double[N];
> adouble* y = new adouble[N];
>
> for (int i = 0; i < N; ++i) x[i] <<= px[i];
>
> #pragma omp parallel ADOLC_OPENMP_NC
> {
> #pragma omp for
> for (int i = 0; i < N; ++i) {
> y[i] = x[i]*x[i];
> }
> }
>
> for (int i = 0; i < N; ++i) y[i] >>= py[i];
>
> trace_off();
>
> double** J = myalloc(N, N);
> int success = jacobian(tag, N, N, px, J);
> assert(success == 3);
>
> for (int i = 0; i < N; ++i) {
> std::cout << "J[" << i << "][" << i << "]: " << J[i][i]
> << std::endl;
> }
>
>
> ------
>
> This code compiled and ran, but produced an incorrect Jacobian (all zeros). Commenting out the pragmas produced the correct Jacobian.
>
> Is this possible?
>
> Thank you,
> Chris Dembia
> _______________________________________________
> ADOL-C mailing list
> ADOL-C at list.coin-or.org
> https://urldefense.proofpoint.com/v2/url?u=https-3A__list.coin-2Dor.org_mailman_listinfo_adol-2Dc&d=DwICAg&c=Ngd-ta5yRYsqeUsEDgxhcqsYYY1Xs5ogLxWPA_2Wlc4&r=aBCvvzd29GWh7UHb2fS5uRTngreim26BJfB7QQOnw4M&m=6zPWFb0pwKC722AyCvr-FGPxXhfILMYE_neDcBbXm3o&s=CmJFsgGvU5__awt2EzjsYbFq4i-YVviXTXFjBHt26Pg&e=
>
--
Dr. Kshitij Kulshreshtha
Institut für Mathematik,
Universität Paderborn,
Warburger Straße 100,
33098 Paderborn.
Büro: TP21.1.21
Besucheradresse:
Technologiepark 21
33098 Paderborn.
Privatanschrift:
Arnikaweg 62
33100 Paderborn.
More information about the ADOL-C
mailing list