Skip to content

Commit

Permalink
Formatting changes
Browse files Browse the repository at this point in the history
  • Loading branch information
wperkins committed Sep 26, 2023
1 parent bcc5f09 commit e931694
Show file tree
Hide file tree
Showing 8 changed files with 149 additions and 127 deletions.
5 changes: 3 additions & 2 deletions src/opflow/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,9 @@ if(EXAGO_ENABLE_RAJA)
endif()
endif()

set(OPFLOW_SOLVER_SRC solver/ipopt/opflow_ipopt.cpp solver/hiop/opflow_hiop.cpp
solver/hiop/opflow_hiopsparse.cpp solver/hiop/opflow_hiopsparsegpu.cpp
set(OPFLOW_SOLVER_SRC
solver/ipopt/opflow_ipopt.cpp solver/hiop/opflow_hiop.cpp
solver/hiop/opflow_hiopsparse.cpp solver/hiop/opflow_hiopsparsegpu.cpp
)

set(OPFLOW_SRC
Expand Down
4 changes: 2 additions & 2 deletions src/opflow/interface/opflow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3033,8 +3033,8 @@ PetscErrorCode OPFLOWCheckModelSolverCompatibility(OPFLOW opflow) {

hiop_sparsegpu =
static_cast<PetscBool>(opflow->solvername == OPFLOWSOLVER_HIOPSPARSEGPU);
pbpolrajahiopsparse =
static_cast<PetscBool>(opflow->modelname == OPFLOWMODEL_PBPOLRAJAHIOPSPARSE);
pbpolrajahiopsparse = static_cast<PetscBool>(opflow->modelname ==
OPFLOWMODEL_PBPOLRAJAHIOPSPARSE);

if (hiop_sparsegpu && !pbpolrajahiopsparse) {
SETERRQ(PETSC_COMM_SELF, PETSC_ERR_SUP,
Expand Down
2 changes: 1 addition & 1 deletion src/opflow/interface/opflowregi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ PetscErrorCode OPFLOWSolverRegisterAll(OPFLOW opflow) {
ierr = OPFLOWSolverRegister(opflow, OPFLOWSOLVER_HIOPSPARSEGPU,
OPFLOWSolverCreate_HIOPSPARSEGPU);
CHKERRQ(ierr);
#endif
#endif
#endif
#endif
opflow->OPFLOWSolverRegisterAllCalled = PETSC_TRUE;
Expand Down
10 changes: 5 additions & 5 deletions src/opflow/model/power_bal_hiop/paramsrajahiop.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -774,9 +774,10 @@ void PbpolModelRajaHiop::destroy(OPFLOW opflow) {
genparams.destroy(opflow);

#ifdef EXAGO_ENABLE_GPU
if(i_jaceq != NULL) {
// These arrays get allocated only with sparse GPU model. For other models, they are
// not allocated. Hence, this business of checking if the array is NULL
if (i_jaceq != NULL) {
// These arrays get allocated only with sparse GPU model. For other models,
// they are not allocated. Hence, this business of checking if the array is
// NULL

auto &resmgr = umpire::ResourceManager::getInstance();
umpire::Allocator h_allocator_ = resmgr.getAllocator("HOST");
Expand All @@ -789,12 +790,11 @@ void PbpolModelRajaHiop::destroy(OPFLOW opflow) {
h_allocator_.deallocate(j_hess);
h_allocator_.deallocate(val_hess);

if(opflow->nconineq) {
if (opflow->nconineq) {
h_allocator_.deallocate(i_jacineq);
h_allocator_.deallocate(j_jacineq);
h_allocator_.deallocate(val_jacineq);
}
}
#endif
}

12 changes: 8 additions & 4 deletions src/opflow/model/power_bal_hiop/paramsrajahiop.h
Original file line number Diff line number Diff line change
Expand Up @@ -248,9 +248,13 @@ struct PbpolModelRajaHiop : public _p_FormPBPOLRAJAHIOP {
LINEParamsRajaHiop lineparams;
BUSParamsRajaHiop busparams;

// Arrays to store Jacobian and Hessian indices and entries on CPU (used with GPU sparse model)
int *i_jaceq,*j_jaceq; // Row and column indices for equality constrained Jacobian
int *i_jacineq, *j_jacineq; // Row and column indices for inequality constrained Jacobain
// Arrays to store Jacobian and Hessian indices and entries on CPU (used with
// GPU sparse model)
int *i_jaceq,
*j_jaceq; // Row and column indices for equality constrained Jacobian
int *i_jacineq,
*j_jacineq; // Row and column indices for inequality constrained Jacobain
int *i_hess, *j_hess; // Row and column indices for hessian
double *val_jaceq,*val_jacineq,*val_hess; // values for equality, inequality jacobians and hessian
double *val_jaceq, *val_jacineq,
*val_hess; // values for equality, inequality jacobians and hessian
};
26 changes: 13 additions & 13 deletions src/opflow/model/power_bal_hiop/pbpolrajahiopsparse.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -260,14 +260,9 @@ extern PetscErrorCode OPFLOWComputeInequalityConstraintJacobian_PBPOL(OPFLOW,
Vec, Mat);
extern PetscErrorCode OPFLOWComputeHessian_PBPOL(OPFLOW, Vec, Vec, Vec, Mat);

extern PetscErrorCode OPFLOWSolutionCallback_PBPOLRAJAHIOPSPARSE (
OPFLOW,
const double*,
const double*,
const double *,
const double *,
const double *,
double);
extern PetscErrorCode OPFLOWSolutionCallback_PBPOLRAJAHIOPSPARSE(
OPFLOW, const double *, const double *, const double *, const double *,
const double *, double);

PetscErrorCode OPFLOWModelCreate_PBPOLRAJAHIOPSPARSE(OPFLOW opflow) {

Expand All @@ -277,7 +272,8 @@ PetscErrorCode OPFLOWModelCreate_PBPOLRAJAHIOPSPARSE(OPFLOW opflow) {

opflow->model = pbpolrajahiopsparse;

/* PBPOLRAJAHIOPSPARSE models only support VARIABLE_WITHIN_BOUNDS opflow->genbusvoltagetype
/* PBPOLRAJAHIOPSPARSE models only support VARIABLE_WITHIN_BOUNDS
* opflow->genbusvoltagetype
*/
opflow->genbusvoltagetype = VARIABLE_WITHIN_BOUNDS;

Expand All @@ -287,7 +283,8 @@ PetscErrorCode OPFLOWModelCreate_PBPOLRAJAHIOPSPARSE(OPFLOW opflow) {
opflow->modelops.destroy = OPFLOWModelDestroy_PBPOLRAJAHIOPSPARSE;
opflow->modelops.setnumvariables = OPFLOWModelSetNumVariables_PBPOL;
opflow->modelops.setnumconstraints = OPFLOWModelSetNumConstraints_PBPOL;
opflow->modelops.setvariablebounds = OPFLOWSetVariableBounds_PBPOLRAJAHIOPSPARSE;
opflow->modelops.setvariablebounds =
OPFLOWSetVariableBounds_PBPOLRAJAHIOPSPARSE;
opflow->modelops.setvariableboundsarray =
OPFLOWSetVariableBoundsArray_PBPOLRAJAHIOPSPARSE;
opflow->modelops.setconstraintbounds =
Expand All @@ -307,16 +304,19 @@ PetscErrorCode OPFLOWModelCreate_PBPOLRAJAHIOPSPARSE(OPFLOW opflow) {
OPFLOWComputeGradientArray_PBPOLRAJAHIOPSPARSE;
opflow->modelops.solutiontops = OPFLOWSolutionToPS_PBPOLRAJAHIOPSPARSE;
opflow->modelops.setup = OPFLOWModelSetUp_PBPOLRAJAHIOPSPARSE;
opflow->modelops.computeequalityconstraintjacobian = OPFLOWComputeEqualityConstraintJacobian_PBPOL;
opflow->modelops.computeequalityconstraintjacobian =
OPFLOWComputeEqualityConstraintJacobian_PBPOL;
opflow->modelops.computesparseequalityconstraintjacobianhiop =
OPFLOWComputeSparseEqualityConstraintJacobian_PBPOLRAJAHIOPSPARSE;
opflow->modelops.computeinequalityconstraintjacobian = OPFLOWComputeInequalityConstraintJacobian_PBPOL;
opflow->modelops.computeinequalityconstraintjacobian =
OPFLOWComputeInequalityConstraintJacobian_PBPOL;
opflow->modelops.computesparseinequalityconstraintjacobianhiop =
OPFLOWComputeSparseInequalityConstraintJacobian_PBPOLRAJAHIOPSPARSE;
opflow->modelops.computehessian = OPFLOWComputeHessian_PBPOL;
opflow->modelops.computesparsehessianhiop =
OPFLOWComputeSparseHessian_PBPOLRAJAHIOPSPARSE;
opflow->modelops.solutioncallbackhiop = OPFLOWSolutionCallback_PBPOLRAJAHIOPSPARSE;
opflow->modelops.solutioncallbackhiop =
OPFLOWSolutionCallback_PBPOLRAJAHIOPSPARSE;

PetscFunctionReturn(0);
}
Expand Down
Loading

0 comments on commit e931694

Please sign in to comment.