Skip to content

Commit ae41f2b

Browse files
committed
wraped up the PR
* updated doc for BUILD.sh and set RAJA and UMPIRE to OFF default values for the build system * removed addToSymDenseMatrixUpperTriangle and documented transAddToSymDenseMatrixUpperTriangle * added unit tests for addUpperTriangleToSymDenseMatrixUpperTriangle. * updated README with minimal RAJA/UMPIRE information * put assert / warnings in LA factory when mem space is not available
1 parent ef195e0 commit ae41f2b

22 files changed

+271
-434
lines changed

BUILD.sh

+15
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,20 @@
11
#!/bin/bash
22

3+
#
4+
# A script file that builds and runs/tests HiOp on various paricular clusters, such as
5+
# summit and ascent @ ORNL and newell and marianas @ PNNL
6+
#
7+
# Usage: In a shell run
8+
#
9+
# ./BUILD.sh
10+
#
11+
#
12+
# Sometimes the cluster name is not detected correctly; in this cases, one can specify
13+
# the cluster name by prefixing the command with MY_CLUSTER=cluster_name, e.g.,
14+
#
15+
# MY_CLUSTER=ascent ./BUILD.sh
16+
#
17+
318
cleanup() {
419
echo
520
echo Exit code $1 caught in build script.

CMakeLists.txt

+2-2
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ option(HIOP_USE_GPU "Build with support for GPUs - Magma and cuda libraries" OFF
2222
option(HIOP_TEST_WITH_BSUB "Use `jsrun` instead of `mpirun` commands when running tests" OFF)
2323
option(HIOP_USE_UMPIRE "Build with portable memory management library Umpire" ON)
2424
option(HIOP_USE_RAJA "Build with portability abstraction library RAJA" ON)
25-
option(HIOP_DEEPCHECKS "Extra checks and asserts in the code with a high penalty on performance" ON)
26-
option(HIOP_WITH_KRON_REDUCTION "Build Kron Reduction code (requires MA86)" OFF)
25+
option(HIOP_DEEPCHECKS "Extra checks and asserts in the code with a high penalty on performance" OFF)
26+
option(HIOP_WITH_KRON_REDUCTION "Build Kron Reduction code (requires UMFPACK)" OFF)
2727
option(HIOP_DEVELOPER_MODE "Build with extended warnings and options" OFF)
2828
#with testing drivers capable of 'selfchecking' (-selfcheck)
2929
option(HIOP_WITH_MAKETEST "Enable 'make test'" ON)

README.md

+10-3
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,11 @@ $> cmake -DCMAKE_INSTALL_PREFIX=/usr/lib/hiop ..'
1818
```
1919
2020
21-
### HiOp-specific build options
21+
### Selected HiOp-specific build options
2222
* Enable/disable MPI: *-DHIOP_USE_MPI=[ON/OFF]* (by default ON)
2323
* GPU support: *-DHIOP_USE_GPU=ON*. MPI can be either off or on. For more build system options related to GPUs, see "Dependencies" section below.
24+
* Use RAJA portability layer to allow running linear algebra in either host (CPU) or device (GPU): *-DHIOP_USE_RAJA=ON* and *-DHIOP_USE_UMPIRE=ON*. These build options are off by default. Currently, HiOp only supports unified memory space.
25+
* Enable/disable "developer mode" build that enforces more restrictive compiler rules and guidelines: *-DHIOP_DEVELOPER_MODE=ON*. This option is by default off.
2426
* Additional checks and self-diagnostics inside HiOp meant to detect anormalities and help to detect bugs and/or troubleshoot problematic instances: *-DHIOP_DEEPCHECKS=[ON/OFF]* (by default ON). Disabling HIOP_DEEPCHECKS usually provides 30-40% execution speedup in HiOp. For full strength, it is recomended to use HIOP_DEEPCHECKS with debug builds. With non-debug builds, in particular the ones that disable the assert macro, HIOP_DEEPCHECKS does not perform all checks and, thus, may overlook potential issues.
2527
2628
For example:
@@ -41,6 +43,8 @@ HiOp requires LAPACK and BLAS. These dependencies are automatically detected by
4143
4244
HiOp has some support for NVIDIA **GPU-based computations** via CUDA and Magma. To enable the use of GPUs, use cmake with '-DHIOP_USE_GPU=ON'. The build system will automatically search for CUDA Toolkit. For non-standard CUDA Toolkit installations, use '-DHIOP_CUDA_LIB_DIR=/path' and '-DHIOP_CUDA_INCLUDE_DIR=/path'. For "very" non-standard CUDA Toolkit installations, one can specify the directory of cuBlas libraries as well with '-DHIOP_CUBLAS_LIB_DIR=/path'.
4345
46+
When RAJA-based portability abstraction layer is enabled, HiOp requires RAJA and UMPIRE libraries
47+
4448
### Support for GPU computations
4549
4650
When GPU support is on, HiOp requires Magma and CUDA Toolkit. Both are detected automatically in most normal use. The typical cmake command to enable GPU support in HiOp is
@@ -67,6 +71,8 @@ $> cmake -DHIOP_USE_GPU=ON -DCUDA_cublas_LIBRARY=/usr/local/cuda-10.2/targets/x8
6771
6872
A detailed example on how to compile HiOp straight of the box on `summit.olcf.ornl.gov` is available [here](README_summit.md).
6973
74+
RAJA and UMPIRE dependencies are usually detected by HiOp's cmake build system.
75+
7076
### Kron reduction
7177

7278
Kron reduction functionality of HiOp is disabled by default. One can enable it by using
@@ -85,7 +91,7 @@ HiOp supports two input formats: `hiopInterfaceDenseConstraints` and `hiopInterf
8591

8692
*`hiopInterfaceDenseConstraints` interface* supports NLPs with **billions** of variables with and without bounds but only limited number (<100) of general, equality and inequality constraints. The underlying algorithm is a limited-memory quasi-Newton interior-point method and generally scales well computationally (but it may not algorithmically) on thousands of cores. This interface uses MPI for parallelization
8793

88-
*`hiopInterfaceMDS` interface* supports mixed dense-sparse NLPs and achives parallelization using GPUs. Limited speed-up can be obtained on multi-cores CPUs via multithreaded MKL.
94+
*`hiopInterfaceMDS` interface* supports mixed dense-sparse NLPs and achives parallelization using GPUs and RAJA portability abstraction layer.
8995

9096
More information on the HiOp interfaces are [here](src/Interface/README.md).
9197

@@ -111,7 +117,8 @@ HiOp has been developed under the financial support of:
111117
- Lawrence Livermore National Laboratory, through the LDRD program
112118
113119
# Copyright
114-
Copyright (c) 2017, Lawrence Livermore National Security, LLC. All rights reserved. Produced at the Lawrence Livermore National Laboratory. LLNL-CODE-742473. Written by Cosmin G. Petra, [email protected].
120+
Copyright (c) 2017, Lawrence Livermore National Security, LLC. All rights reserved. Produced at the Lawrence Livermore National Laboratory. LLNL-CODE-742473.
121+
HiOp is written by Cosmin G. Petra ([email protected]) of LLNL and has received contributions from Slaven Peles (PNNL), Asher Mancinelli (PNNL), Jake K. Ryan (PNNL), Cameron Rutherford (PNNL), Nai-Yuan Chiang (LLNL), and Michel Schanen (ANL).
115122
116123
HiOp is free software; you can modify it and/or redistribute it under the terms of the BSD 3-clause license. See [COPYRIGHT](/COPYRIGHT) and [LICENSE](/LICENSE) for complete copyright and license information.
117124

src/Drivers/nlpMDS_ex4_raja_driver.cpp

-2
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@
1616

1717
using namespace hiop;
1818

19-
static bool self_check(long long n, double obj_value);
20-
2119
static bool parse_arguments(int argc, char **argv,
2220
bool& self_check,
2321
long long& n_sp,

src/LinAlg/hiopLinAlgFactory.cpp

+24
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,10 @@ hiopVector* LinearAlgebraFactory::createVector(
9595
{
9696
#ifdef HIOP_USE_RAJA
9797
return new hiopVectorRajaPar(glob_n, mem_space_, col_part, comm);
98+
#else
99+
assert(false && "requested memory space not available because Hiop was not"
100+
"built with RAJA support");
101+
return new hiopVectorPar(glob_n, col_part, comm);
98102
#endif
99103
}
100104
}
@@ -115,6 +119,10 @@ hiopVectorInt* LinearAlgebraFactory::createVectorInt(int size)
115119
{
116120
#ifdef HIOP_USE_RAJA
117121
return new hiopVectorIntRaja(size, mem_space_);
122+
#else
123+
assert(false && "requested memory space not available because Hiop was not"
124+
"built with RAJA support");
125+
return new hiopVectorIntSeq(size);
118126
#endif
119127
}
120128
}
@@ -140,6 +148,10 @@ hiopMatrixDense* LinearAlgebraFactory::createMatrixDense(
140148
{
141149
#ifdef HIOP_USE_RAJA
142150
return new hiopMatrixRajaDense(m, glob_n, mem_space_, col_part, comm, m_max_alloc);
151+
#else
152+
assert(false && "requested memory space not available because Hiop was not"
153+
"built with RAJA support");
154+
return new hiopMatrixDenseRowMajor(m, glob_n, col_part, comm, m_max_alloc);
143155
#endif
144156
}
145157

@@ -159,6 +171,10 @@ hiopMatrixSparse* LinearAlgebraFactory::createMatrixSparse(int rows, int cols, i
159171
{
160172
#ifdef HIOP_USE_RAJA
161173
return new hiopMatrixRajaSparseTriplet(rows, cols, nnz, mem_space_);
174+
#else
175+
assert(false && "requested memory space not available because Hiop was not"
176+
"built with RAJA support");
177+
return new hiopMatrixSparseTriplet(rows, cols, nnz);
162178
#endif
163179
}
164180
}
@@ -177,6 +193,10 @@ hiopMatrixSparse* LinearAlgebraFactory::createMatrixSymSparse(int size, int nnz)
177193
{
178194
#ifdef HIOP_USE_RAJA
179195
return new hiopMatrixRajaSymSparseTriplet(size, nnz, mem_space_);
196+
#else
197+
assert(false && "requested memory space not available because Hiop was not"
198+
"built with RAJA support");
199+
return new hiopMatrixSymSparseTriplet(size, nnz);
180200
#endif
181201
}
182202
}
@@ -196,6 +216,10 @@ double* LinearAlgebraFactory::createRawArray(int n)
196216
auto& resmgr = umpire::ResourceManager::getInstance();
197217
umpire::Allocator al = resmgr.getAllocator(mem_space_);
198218
return static_cast<double*>(al.allocate(n*sizeof(double)));
219+
#else
220+
assert(false && "requested memory space not available because Hiop was not"
221+
"built with RAJA support");
222+
return new double[n];
199223
#endif
200224
}
201225
}

src/LinAlg/hiopMatrix.hpp

+10-16
Original file line numberDiff line numberDiff line change
@@ -128,38 +128,32 @@ class hiopMatrix
128128
/// @brief this += alpha*X
129129
virtual void addMatrix(double alpha, const hiopMatrix& X) = 0;
130130

131-
/**
132-
* @brief block of W += alpha*this
133-
*
134-
* For efficiency, only upper triangular matrix is updated since this will be eventually sent to LAPACK
135-
*
136-
* @pre 'this' fits in the upper triangle of W
137-
* @pre W.n() == W.m()
138-
* @pre 'this' and W are local/non-distributed matrices
139-
*/
140-
virtual void addToSymDenseMatrixUpperTriangle(int row_dest_start, int col_dest_start,
141-
double alpha, hiopMatrixDense& W) const = 0;
142-
143131
/**
144132
* @brief block of W += alpha*transpose(this)
145133
*
146134
* For efficiency, only upper triangular matrix is updated since this will be eventually sent to LAPACK
147135
*
136+
* The functionality of this method is needed only for general (non-symmetric) matrices and, for this
137+
* reason, only general matrices classes implement/need to implement this method.
138+
*
148139
* @pre transpose of 'this' fits in the upper triangle of W
149140
* @pre W.n() == W.m()
150141
* @pre 'this' and W are local/non-distributed matrices
151142
*/
152143
virtual void transAddToSymDenseMatrixUpperTriangle(int row_dest_start, int col_dest_start,
153-
double alpha, hiopMatrixDense& W) const = 0;
144+
double alpha, hiopMatrixDense& W) const = 0;
154145

155146
/**
156147
* @brief diagonal block of W += alpha*this with 'diag_start' indicating the diagonal entry of W where
157-
* 'this' should start to contribute.
148+
* 'this' should start to contribute to.
158149
*
159150
* For efficiency, only upper triangle of W is updated since this will be eventually sent to LAPACK
160-
* and only the upper triangle of 'this' is accessed
151+
* and only the upper triangle of 'this' is accessed.
161152
*
162-
* @pre this->n()==this-m()
153+
* This functionality of this method is needed only for symmetric matrices and, for this reason,
154+
* only symmetric matrices classes implement/need to implement it.
155+
*
156+
* @pre this->n()==this->m()
163157
* @pre W.n() == W.m()
164158
* @pre 'this' and W are local/non-distributed matrices
165159
*/

src/LinAlg/hiopMatrixComplexDense.hpp

-12
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ namespace hiop
2424
- timesMatTran_local
2525
- addDiagonal (both overloads)
2626
- addSubDiagonal (all three overloads)
27-
- addToSymDenseMatrixUpperTriangle
2827
- transAddToSymDenseMatrixUpperTriangle
2928
- addUpperTriangleToSymDenseMatrixUpperTriangle
3029
- copyRowsFrom
@@ -155,17 +154,6 @@ namespace hiop
155154
void addSparseSymUpperTriangleToSymDenseMatrixUpperTriangle(const std::complex<double>& alpha,
156155
const hiopMatrixComplexSparseTriplet& X);
157156

158-
/* block of W += alpha*this
159-
* For efficiency, only upper triangular matrix is updated since this will be eventually sent to LAPACK
160-
* Preconditions:
161-
* 1. 'this' has to fit in the upper triangle of W
162-
* 2. W.n() == W.m()
163-
*/
164-
virtual void addToSymDenseMatrixUpperTriangle(int row_dest_start, int col_dest_start,
165-
double alpha, hiopMatrixDense& W) const
166-
{
167-
assert(false && "not supported");
168-
}
169157
/* block of W += alpha*transpose(this)
170158
* For efficiency, only upper triangular matrix is updated since this will be eventually sent to LAPACK
171159
* Preconditions:

src/LinAlg/hiopMatrixDense.hpp

+4-10
Original file line numberDiff line numberDiff line change
@@ -135,15 +135,6 @@ class hiopMatrixDense : public hiopMatrix
135135

136136
virtual void addMatrix(double alpha, const hiopMatrix& X){assert(false && "not implemented in base class");}
137137

138-
/**
139-
* @brief block of W += alpha*this
140-
* For efficiency, only upper triangular matrix is updated since this will be eventually sent to LAPACK
141-
*
142-
* @pre 'this' has to fit in the upper triangle of W
143-
* @pre W.n() == W.m()
144-
*/
145-
virtual void addToSymDenseMatrixUpperTriangle(int row_dest_start, int col_dest_start,
146-
double alpha, hiopMatrixDense& W) const{assert(false && "not implemented in base class");}
147138
/**
148139
* @brief block of W += alpha*transpose(this)
149140
* For efficiency, only upper triangular matrix is updated since this will be eventually sent to LAPACK
@@ -152,7 +143,10 @@ class hiopMatrixDense : public hiopMatrix
152143
* @pre W.n() == W.m()
153144
*/
154145
virtual void transAddToSymDenseMatrixUpperTriangle(int row_dest_start, int col_dest_start,
155-
double alpha, hiopMatrixDense& W) const{assert(false && "not implemented in base class");}
146+
double alpha, hiopMatrixDense& W) const
147+
{
148+
assert(false && "not implemented in base class");
149+
}
156150

157151
/**
158152
* @brief diagonal block of W += alpha*this with 'diag_start' indicating the diagonal entry of W where

src/LinAlg/hiopMatrixDenseRowMajor.cpp

-20
Original file line numberDiff line numberDiff line change
@@ -714,26 +714,6 @@ void hiopMatrixDenseRowMajor::addMatrix(double alpha, const hiopMatrix& X_)
714714
DAXPY(&N, &alpha, X.M_[0], &inc, M_[0], &inc);
715715
}
716716

717-
/* block of W += alpha*this
718-
* starts are in destination */
719-
void hiopMatrixDenseRowMajor::addToSymDenseMatrixUpperTriangle(int row_start, int col_start,
720-
double alpha, hiopMatrixDense& W) const
721-
{
722-
assert(row_start>=0 && m()+row_start<=W.m());
723-
assert(col_start>=0 && n()+col_start<=W.n());
724-
assert(W.n()==W.m());
725-
726-
double** WM = W.get_M();
727-
for(int i=0; i<m_local_; i++) {
728-
const int iW = i+row_start;
729-
for(int j=0; j<n_local_; j++) {
730-
const int jW = j+col_start;
731-
assert(iW<=jW && "source entries need to map inside the upper triangular part of destination");
732-
WM[iW][jW] += alpha*this->M_[i][j];
733-
}
734-
}
735-
}
736-
737717
/* block of W += alpha*this' */
738718
void hiopMatrixDenseRowMajor::transAddToSymDenseMatrixUpperTriangle(int row_start, int col_start,
739719
double alpha, hiopMatrixDense& W) const

src/LinAlg/hiopMatrixDenseRowMajor.hpp

+3-10
Original file line numberDiff line numberDiff line change
@@ -136,16 +136,6 @@ class hiopMatrixDenseRowMajor : public hiopMatrixDense
136136

137137
virtual void addMatrix(double alpha, const hiopMatrix& X);
138138

139-
/**
140-
* @brief block of W += alpha*this
141-
* For efficiency, only upper triangular matrix is updated since this will be eventually sent to LAPACK
142-
*
143-
* @pre 'this' has to fit in the upper triangle of W
144-
* @pre W.n() == W.m()
145-
*/
146-
virtual void addToSymDenseMatrixUpperTriangle(int row_dest_start, int col_dest_start,
147-
double alpha, hiopMatrixDense& W) const;
148-
149139
/**
150140
* @brief block of W += alpha*transpose(this)
151141
* For efficiency, only upper triangular matrix is updated since this will be eventually sent to LAPACK
@@ -163,6 +153,9 @@ class hiopMatrixDenseRowMajor : public hiopMatrixDense
163153
* For efficiency, only upper triangle of W is updated since this will be eventually sent to LAPACK
164154
* and only the upper triangle of 'this' is accessed
165155
*
156+
* This functionality of this method is needed only for symmetric matrices and, for this reason,
157+
* only symmetric matrices classes implement/need to implement it.
158+
*
166159
* @pre this->n()==this->m()
167160
* @pre W.n() == W.m()
168161
*/

src/LinAlg/hiopMatrixMDS.hpp

+12-25
Original file line numberDiff line numberDiff line change
@@ -133,11 +133,12 @@ class hiopMatrixMDS : public hiopMatrix
133133
}
134134

135135
/* block of W += alpha*this */
136-
virtual void addToSymDenseMatrixUpperTriangle(int row_start, int col_start, double alpha, hiopMatrixDense& W) const
137-
{
138-
mSp->addToSymDenseMatrixUpperTriangle(row_start, col_start, alpha, W);
139-
mDe->addToSymDenseMatrixUpperTriangle(row_start, col_start+mSp->n(), alpha, W);
140-
}
136+
// virtual void addToSymDenseMatrixUpperTriangle(int row_start, int col_start, double alpha, hiopMatrixDense& W) const
137+
// {
138+
// mSp->addToSymDenseMatrixUpperTriangle(row_start, col_start, alpha, W);
139+
// mDe->addToSymDenseMatrixUpperTriangle(row_start, col_start+mSp->n(), alpha, W);
140+
// } aaa
141+
141142
/* block of W += alpha*this' */
142143
virtual void transAddToSymDenseMatrixUpperTriangle(int row_start, int col_start, double alpha, hiopMatrixDense& W) const
143144
{
@@ -158,7 +159,7 @@ class hiopMatrixMDS : public hiopMatrix
158159
virtual void addUpperTriangleToSymDenseMatrixUpperTriangle(int diag_start,
159160
double alpha, hiopMatrixDense& W) const
160161
{
161-
assert(false && "not for general matrices; counterpart method from hiopMatrixSymBlockDiagMDS should be used instead");
162+
assert(false && "not needed for general/nonsymmetric matrices.");
162163
}
163164

164165
virtual double max_abs_value()
@@ -238,7 +239,6 @@ class hiopMatrixMDS : public hiopMatrix
238239
* - timesMatTran
239240
* - addDiagonal (both overloads)
240241
* - addSubDiagonal (all three overloads)
241-
* - addToSymDenseMatrixUpperTriangle
242242
* - transAddToSymDenseMatrixUpperTriangle
243243
*/
244244
class hiopMatrixSymBlockDiagMDS : public hiopMatrix
@@ -346,26 +346,13 @@ class hiopMatrixSymBlockDiagMDS : public hiopMatrix
346346
/**
347347
* block of W += alpha*this
348348
*
349-
* @todo Should this method be available at all? Consider using
350-
* addUpperTriangleToSymDenseMatrixUpperTriangle instead.
351-
*/
352-
virtual void addToSymDenseMatrixUpperTriangle(int row_start, int col_start, double alpha, hiopMatrixDense& W) const
353-
{
354-
assert(mSp->m() == mSp->n());
355-
mSp->addToSymDenseMatrixUpperTriangle(row_start, col_start, alpha, W);
356-
mDe->addToSymDenseMatrixUpperTriangle(row_start+mSp->n(), col_start+mSp->n(), alpha, W);
357-
assert(0 && "This should not be called for symmetric matrices.");
358-
}
359-
/**
360-
* block of W += alpha*this
361-
*
362-
* @warning This method is implemented correctly, but should never be called actually.
349+
* @warning This method should never be called/is never needed for symmetric matrixes.
363350
* Use addUpperTriangleToSymDenseMatrixUpperTriangle instead.
364351
*/
365-
virtual void transAddToSymDenseMatrixUpperTriangle(int row_start, int col_start, double alpha, hiopMatrixDense& W) const
352+
virtual void transAddToSymDenseMatrixUpperTriangle(int row_start, int col_start,
353+
double alpha, hiopMatrixDense& W) const
366354
{
367-
addToSymDenseMatrixUpperTriangle(row_start, col_start, alpha, W);
368-
assert(0 && "This should not be called for symmetric matrices.");
355+
assert(0 && "This should not be called for MDS symmetric matrices.");
369356
}
370357

371358
/* diagonal block of W += alpha*this with 'diag_start' indicating the diagonal entry of W where
@@ -375,7 +362,7 @@ class hiopMatrixSymBlockDiagMDS : public hiopMatrix
375362
* and only the upper triangle of 'this' is accessed
376363
*
377364
* Preconditions:
378-
* 1. this->n()==this-m()
365+
* 1. this->n()==this->m()
379366
* 2. W.n() == W.m()
380367
*/
381368
virtual void addUpperTriangleToSymDenseMatrixUpperTriangle(int diag_start,

0 commit comments

Comments
 (0)