[ADOL-C] Using Adol-C with OpenMP
Kshitij Kulshreshtha
kshitij at math.upb.de
Wed Feb 19 11:29:10 EST 2014
Hello,
unfortunately the OpenMP interface isn't well tested and a lot of the
OpenMP specification, that would help us design a better interface in
ADOL-C is still theoretical and was not implemented in compilers like
gcc the last time I took a look at it. (e.g. threadprivate)
The only way the current interface works for sure that I know of is the
following. You start the parallel section before the trace_on() call with
#pragma openmp parallel ADOLC_OPENMP
{
...
trace_on(tag);
....
// somewhere here you can have
#pragma openmp for
for (...) { ... }
trace_off();
// and then all the derivative computations
gradient(tag,...);
hess_vec(tag,...);
sparse_hess(tag,...);
//etc.
}
You should also try out the svn trunk version. As we are just a little
bit away from releasing ADOL-C vesion 2.5.0
There have been some drastic changes in the internal memory management
since version 2.4.0 so maybe that will get rid of the error you encounter.
Cheers
Kshitij.
As on 2014-02-19 16:33h, Pierre Martinon did write:
> Hello everyone,
>
> I have been trying to use Adol-C in combination with OpenMP, and I got a
> bit confused between the manual and the example.
> The sequential version of the code runs fine, the openmp part without
> automatic differentiation seems to be correct as well.
>
> I built Adol-C 2.4.0 and Colpack 1.0.9 with OpenMP enabled.
> (during the make for Adol-C I encountered an error about a missing
> adolc_openmp.h, copying the file into src/ seemed to solve the issue)
>
> The tape is something like
>
> / trace_on(tag_L);//
> // for(i=0; i < n; i++)//
> // m_x_ad[i] <<= 1e0;//
> // for(i=0; i < m; i++)//
> // m_lambda_ad[i] <<= 1e0;//
> // m_objfactor_ad <<= 1e0;//
> // evalObjective(n,m_x_ad,m_objvalue_ad);//
> // m_lagvalue_ad = m_objvalue_ad * m_objfactor_ad;//
> // evalConstraints(n,m_x_ad,m,m_g_ad);//
> // for(i=0; i < m; i++)//
> // m_lagvalue_ad += m_g_ad[i] * m_lambda_ad[i];//
> // m_lagvalue_ad >>= dummy;//
> // trace_off();/
>
> / // build sparsity pattern//
> // m_row_hess_total = NULL;//
> // m_col_hess_total = NULL;//
> // m_val_hess = NULL;//
> // m_options_hess[0] = 0;//
> // m_options_hess[1] = 1; //
> //
> // // full Hessian wrt (x,lambda,objfactor)//
> // sparse_hess(tag_L, n+m+1, 0, m_xlf, &m_nnz_hess_total,
> &m_row_hess_total, &m_col_hess_total, &m_val_hess, m_options_hess);/
>
> and somewhere in the function evalConstraints I have an openMP loop
>
> / #pragma omp parallel for default(none) shared(...) schedule(dynamic) /
> / for (int i=0; ....)//
> // {//
> // ...//
> // }/
>
> I added the #include <adolc/adolc_openmp.h>, and the ADOLC_OPENMP macro
> at the end of the pragma.
> Is it supposed to be enough ?
>
> Currently I get these errors during the call to evalConstraints (before
> the actual call to sparse_hessian)
>
> /bocop: tape_handling.cpp:1373: virtual void
> StoreManagerLocintBlock::free_loc(locint): Assertion `loc < maxsize'
> failed.//
> /
>
> Any help would be greatly appreciated,
>
> Pierre Martinon
>
>
> _______________________________________________
> ADOL-C mailing list
> ADOL-C at list.coin-or.org
> http://list.coin-or.org/mailman/listinfo/adol-c
>
--
Dr. Kshitij Kulshreshtha
Institut für Mathematik,
Universität Paderborn,
Warburger Straße 100,
33098 Paderborn.
Büro: A3.235
Privatanschrift:
Arnikaweg 62
33100 Paderborn.
More information about the ADOL-C
mailing list