Skip to content

Commit 5472ad1

Browse files
committed
[FIX] Improve build system when compiling with colpack
1 parent 7c5fc3f commit 5472ad1

File tree

14 files changed

+232
-206
lines changed

14 files changed

+232
-206
lines changed

ADOL-C/include/adolc/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ install(FILES
55
adolcexport.h
66
adolc.h
77
adolc_openmp.h
8-
adolc_sparse.h
98
adoublecuda.h
109
adtl.h
1110
adtl_hov.h

ADOL-C/include/adolc/adolc.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
#if defined(__cplusplus)
2626
/*--------------------------------------------------------------------------*/
2727
/* Operator overloading things (active doubles & vectors) */
28-
#include <adolc/adolc_sparse.h>
2928
#include <adolc/adtb_types.h>
3029
#include <adolc/checkpointing.h>
3130
#include <adolc/edfclasses.h>
@@ -54,8 +53,8 @@
5453
#include <adolc/tapedoc/tapedoc.h>
5554

5655
/*--------------------------------------------------------------------------*/
57-
/* interfaces to SPARSE package */
58-
#if defined(SPARSE_DRIVERS)
56+
/* interfaces to sparse drivers */
57+
#ifdef ADOLC_SPARSE
5958
#include <adolc/sparse/sparse_fo_rev.h>
6059
#include <adolc/sparse/sparsedrivers.h>
6160
#endif

ADOL-C/include/adolc/adolc_sparse.h

Lines changed: 0 additions & 16 deletions
This file was deleted.

ADOL-C/include/adolc/internal/adolc_settings.h.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ typedef double revreal;
3737

3838
/*--------------------------------------------------------------------------*/
3939
/* Sparse drivers have been compiled */
40-
@SPARSE_DRIVERS@
40+
@ADOLC_SPARSE@
4141

4242
/*--------------------------------------------------------------------------*/
4343
/* Use Boost Library Pool allocator */

ADOL-C/include/adolc/sparse/sparse_fo_rev.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ package.
1515
----------------------------------------------------------------------------*/
1616
#ifndef ADOLC_SPARSE_FO_REV_H
1717
#define ADOLC_SPARSE_FO_REV_H
18-
1918
#include <adolc/adolcexport.h>
2019
#include <adolc/internal/common.h>
2120
#include <vector>
@@ -74,5 +73,4 @@ ADOLC_API int reverse(short tag, int m, int n, int q,
7473
std::vector<bitword_t *> &U, std::vector<bitword_t *> &Z,
7574
char mode);
7675
} // namespace ADOLC::Sparse
77-
78-
#endif // ADOLC_SPARSE_FO_REV_H
76+
#endif // ADOLC_SPARSE_FO_REV_H

ADOL-C/include/adolc/sparse/sparsedrivers.h

Lines changed: 22 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,12 @@ package.
1414
----------------------------------------------------------------------------*/
1515
#ifndef ADOLC_SPARSE_DRIVERS_H
1616
#define ADOLC_SPARSE_DRIVERS_H
17-
1817
#include <adolc/adalloc.h>
1918
#include <adolc/adolcerror.h>
2019
#include <adolc/interfaces.h>
2120
#include <adolc/internal/common.h>
2221
#include <adolc/tape_interface.h>
22+
#include <adolc/valuetape/sparseinfos.h>
2323
#include <adolc/valuetape/valuetape.h>
2424
#include <cstddef>
2525
#include <span>
@@ -31,8 +31,6 @@ package.
3131
// (block) variables at once
3232
#define PQ_STRIPMINE_MAX 30
3333

34-
#ifdef SPARSE
35-
#include <ColPack/ColPackHeaders.h>
3634
namespace ADOLC::Sparse {
3735

3836
enum class SparseMethod {
@@ -613,17 +611,12 @@ ADOLC_API int jac_pat(short tag, int depen, int indep, const double *basepoint,
613611
* according to ColPack's unmanaged API semantics.
614612
*/
615613
template <CompressionMode CM>
616-
ADOLC_API void generate_seed_jac(int m, int n, const std::span<uint *> &JP,
614+
ADOLC_API void generate_seed_jac(int m, int n, const std::span<uint *> JP,
617615
double ***Seed, int *p) {
618-
int dummy = 0;
619-
auto g = std::make_unique<ColPack::BipartiteGraphPartialColoringInterface>(
620-
SRC_MEM_ADOLC, JP.data(), m, n);
621616
if constexpr (CM == CompressionMode::Row)
622-
g->GenerateSeedJacobian_unmanaged(Seed, p, &dummy, "SMALLEST_LAST",
623-
"ROW_PARTIAL_DISTANCE_TWO");
617+
generateSeedJac(m, n, JP, Seed, p, "ROW_PARTIAL_DISTANCE_TWO");
624618
else if (CM == CompressionMode::Column)
625-
g->GenerateSeedJacobian_unmanaged(Seed, &dummy, p, "SMALLEST_LAST",
626-
"COLUMN_PARTIAL_DISTANCE_TWO");
619+
generateSeedJac(m, n, JP, Seed, p, "COLUMN_PARTIAL_DISTANCE_TWO");
627620
}
628621

629622
namespace detail {
@@ -700,24 +693,14 @@ int buildJacPatternAndSeed(short tag, int depen, int indep,
700693
}
701694

702695
*nnz = tape.sJInfos().nnzIn_;
703-
704-
tape.sJInfos().g_ =
705-
std::make_unique<ColPack::BipartiteGraphPartialColoringInterface>(
706-
SRC_MEM_ADOLC, tape.sJInfos().getJP().data(), depen, indep);
707-
tape.sJInfos().jr1d_ = std::make_unique<ColPack::JacobianRecovery1D>();
696+
tape.sJInfos().initColoring(depen, indep);
708697

709698
if constexpr (CM == CompressionMode::Row) {
710-
tape.sJInfos().g_->GenerateSeedJacobian(
711-
&(tape.sJInfos().Seed_), &(tape.sJInfos().seedRows_),
712-
&(tape.sJInfos().seedClms_), "SMALLEST_LAST",
713-
"ROW_PARTIAL_DISTANCE_TWO");
699+
tape.sJInfos().generateSeedJac("ROW_PARTIAL_DISTANCE_TWO");
714700
tape.sJInfos().seedClms_ = indep;
715701
ret_val = tape.sJInfos().seedRows_;
716702
} else if (CM == CompressionMode::Column) {
717-
tape.sJInfos().g_->GenerateSeedJacobian(
718-
&(tape.sJInfos().Seed_), &(tape.sJInfos().seedRows_),
719-
&(tape.sJInfos().seedClms_), "SMALLEST_LAST",
720-
"COLUMN_PARTIAL_DISTANCE_TWO");
703+
tape.sJInfos().generateSeedJac("COLUMN_PARTIAL_DISTANCE_TWO");
721704
tape.sJInfos().seedRows_ = depen;
722705
ret_val = tape.sJInfos().seedClms_;
723706
}
@@ -816,13 +799,9 @@ int computeSparseJac(short tag, int depen, int indep, const double *basepoint,
816799
// everything is preallocated, we assume correctly
817800
// call usermem versions
818801
if (CM == CompressionMode::Row)
819-
tape.sJInfos().jr1d_->RecoverD2Row_CoordinateFormat_usermem(
820-
tape.sJInfos().g_.get(), tape.sJInfos().B_, tape.sJInfos().JP_.data(),
821-
rind, cind, values);
802+
tape.sJInfos().recoverRowFormat(rind, cind, values);
822803
else if (CM == CompressionMode::Column)
823-
tape.sJInfos().jr1d_->RecoverD2Cln_CoordinateFormat_usermem(
824-
tape.sJInfos().g_.get(), tape.sJInfos().B_, tape.sJInfos().JP_.data(),
825-
rind, cind, values);
804+
tape.sJInfos().recoverColFormat(rind, cind, values);
826805
} else {
827806
// at least one of rind cind values is not allocated, deallocate others
828807
// and call unmanaged versions
@@ -833,13 +812,9 @@ int computeSparseJac(short tag, int depen, int indep, const double *basepoint,
833812
if (cind != nullptr && *cind != nullptr)
834813
free(*cind);
835814
if (CM == CompressionMode::Row) {
836-
tape.sJInfos().jr1d_->RecoverD2Row_CoordinateFormat_unmanaged(
837-
tape.sJInfos().g_.get(), tape.sJInfos().B_, tape.sJInfos().JP_.data(),
838-
rind, cind, values);
815+
tape.sJInfos().recoverRowFormat(rind, cind, values);
839816
} else if (CM == CompressionMode::Column) {
840-
tape.sJInfos().jr1d_->RecoverD2Cln_CoordinateFormat_unmanaged(
841-
tape.sJInfos().g_.get(), tape.sJInfos().B_, tape.sJInfos().JP_.data(),
842-
rind, cind, values);
817+
tape.sJInfos().recoverColFormat(rind, cind, values);
843818
}
844819
}
845820
return ret_val;
@@ -1012,17 +987,12 @@ ADOLC_API int hess_pat(short tag, int indep, const double *basepoint,
1012987
* returned Seed.
1013988
*/
1014989
template <RecoveryMethod RCM>
1015-
ADOLC_API void generate_seed_hess(int n, std::span<uint *> &HP, double ***Seed,
990+
ADOLC_API void generate_seed_hess(int n, std::span<uint *> HP, double ***Seed,
1016991
int *p) {
1017-
int seed_rows;
1018-
auto g = std::make_unique<ColPack::GraphColoringInterface>(SRC_MEM_ADOLC,
1019-
HP.data(), n);
1020992
if constexpr (RCM == RecoveryMethod::Indirect)
1021-
g->GenerateSeedHessian_unmanaged(Seed, &seed_rows, p, "SMALLEST_LAST",
1022-
"ACYCLIC_FOR_INDIRECT_RECOVERY");
993+
generateSeedHess(n, HP, Seed, p, "ACYCLIC_FOR_INDIRECT_RECOVERY");
1023994
else if (RCM == RecoveryMethod::Direct)
1024-
g->GenerateSeedHessian_unmanaged(Seed, &seed_rows, p, "SMALLEST_LAST",
1025-
"STAR");
995+
generateSeedHess(n, HP, Seed, p, "STAR");
1026996
}
1027997

1028998
namespace detail {
@@ -1066,8 +1036,6 @@ template <ControlFlowMode CFM, RecoveryMethod RCM>
10661036
int buildHessPatternAndSeed(short tag, int indep, const double *basepoint,
10671037
int *nnz) {
10681038
ValueTape &tape = findTape(tag);
1069-
double **Seed;
1070-
int dummy;
10711039
int ret_val = -1;
10721040
// Generate sparsity pattern, determine nnz, allocate memory
10731041
tape.sHInfos().setHP(indep, std::vector<uint *>(indep));
@@ -1093,19 +1061,12 @@ int buildHessPatternAndSeed(short tag, int indep, const double *basepoint,
10931061

10941062
// compute seed matrix => ColPack library
10951063

1096-
Seed = nullptr;
1097-
1098-
tape.sHInfos().g_ = std::make_unique<ColPack::GraphColoringInterface>(
1099-
SRC_MEM_ADOLC, tape.sHInfos().getHP().data(), indep);
1100-
tape.sHInfos().hr_ = std::make_unique<ColPack::HessianRecovery>();
1101-
1064+
double **Seed = nullptr;
1065+
tape.sHInfos().initColoring(indep);
11021066
if constexpr (RCM == RecoveryMethod::Indirect)
1103-
tape.sHInfos().g_->GenerateSeedHessian(&Seed, &dummy, &tape.sHInfos().p_,
1104-
"SMALLEST_LAST",
1105-
"ACYCLIC_FOR_INDIRECT_RECOVERY");
1067+
tape.sHInfos().generateSeedHess(&Seed, "ACYCLIC_FOR_INDIRECT_RECOVERY");
11061068
else if (RCM == RecoveryMethod::Direct)
1107-
tape.sHInfos().g_->GenerateSeedHessian(&Seed, &dummy, &tape.sHInfos().p_,
1108-
"SMALLEST_LAST", "STAR");
1069+
tape.sHInfos().generateSeedHess(&Seed, "STAR");
11091070

11101071
tape.sHInfos().Hcomp_ = myalloc2(indep, tape.sHInfos().p_);
11111072
tape.sHInfos().Xppp_ = myalloc3(indep, tape.sHInfos().p_, 1);
@@ -1195,13 +1156,9 @@ int computeSparseHess(short tag, int indep, const double *basepoint, int *nnz,
11951156
// everything is preallocated, we assume correctly
11961157
// call usermem versions
11971158
if constexpr (RCM == RecoveryMethod::Indirect)
1198-
tape.sHInfos().hr_->IndirectRecover_CoordinateFormat_usermem(
1199-
tape.sHInfos().g_.get(), tape.sHInfos().Hcomp_,
1200-
tape.sHInfos().HP_.data(), rind, cind, values);
1159+
tape.sHInfos().indirectRecoverUserMem(rind, cind, values);
12011160
else if (RCM == RecoveryMethod::Direct)
1202-
tape.sHInfos().hr_->DirectRecover_CoordinateFormat_usermem(
1203-
tape.sHInfos().g_.get(), tape.sHInfos().Hcomp_,
1204-
tape.sHInfos().HP_.data(), rind, cind, values);
1161+
tape.sHInfos().directRecoverUserMem(rind, cind, values);
12051162
} else {
12061163
// at least one of rind cind values is not allocated, deallocate others
12071164
// and call unmanaged versions
@@ -1212,13 +1169,9 @@ int computeSparseHess(short tag, int indep, const double *basepoint, int *nnz,
12121169
if (*cind != nullptr)
12131170
free(*cind);
12141171
if constexpr (RCM == RecoveryMethod::Indirect)
1215-
tape.sHInfos().hr_->IndirectRecover_CoordinateFormat_unmanaged(
1216-
tape.sHInfos().g_.get(), tape.sHInfos().Hcomp_,
1217-
tape.sHInfos().HP_.data(), rind, cind, values);
1172+
tape.sHInfos().indirectRecover(rind, cind, values);
12181173
else if (RCM == RecoveryMethod::Direct)
1219-
tape.sHInfos().hr_->DirectRecover_CoordinateFormat_unmanaged(
1220-
tape.sHInfos().g_.get(), tape.sHInfos().Hcomp_,
1221-
tape.sHInfos().HP_.data(), rind, cind, values);
1174+
tape.sHInfos().directRecover(rind, cind, values);
12221175
}
12231176
return ret_val;
12241177
}
@@ -1277,6 +1230,4 @@ sparse_hess(short tag, int indep, int repeat, const double *basepoint, int *nnz,
12771230
/****************************************************************************/
12781231

12791232
} // namespace ADOLC::Sparse
1280-
1281-
#endif // SPARSE
12821233
#endif // ADOLC_SPARSE_DRIVERS_H

ADOL-C/include/adolc/tape_interface.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,7 @@ ADOLC_API inline size_t get_num_param(short tapeId) {
288288
return findTape(tapeId).get_num_param();
289289
}
290290

291-
#ifdef SPARSE
291+
#ifdef ADOLC_SPARSE
292292
namespace ADOLC::Sparse {
293293
/**
294294
* @brief Sets the Sparse Jacbian Information of the tape
@@ -384,6 +384,6 @@ ADOLC_API inline std::vector<uint *> getHP(short tapeId) {
384384
}
385385

386386
} // namespace ADOLC::Sparse
387-
#endif // SPARSE
387+
#endif // ADOLC_SPARSE
388388

389389
#endif // ADOLC_TAPE_INTERFACE_H

0 commit comments

Comments
 (0)