Actual source code: dlregistao.c

petsc-3.14.6 2021-03-30
Report Typos and Errors
  1: #define TAO_DLL

  3: #include <petsc/private/taoimpl.h>

  5: static PetscBool TaoPackageInitialized = PETSC_FALSE;

  7: /*@C
  8:   TaoFinalizePackage - This function destroys everything in the PETSc/TAO
  9:   interface to the Tao package. It is called from PetscFinalize().

 11:   Level: developer
 12: @*/
 13: PetscErrorCode TaoFinalizePackage(void)
 14: {

 18:   PetscFunctionListDestroy(&TaoList);
 19:   TaoPackageInitialized = PETSC_FALSE;
 20:   return(0);
 21: }

 23: const char *const TaoADMMRegularizerTypes[] = {"REGULARIZER_USER","REGULARIZER_SOFT_THRESH","TaoADMMRegularizerType","TAO_ADMM_",NULL};
 24: const char *const TaoADMMUpdateTypes[]      = {"UPDATE_BASIC","UPDATE_ADAPTIVE","UPDATE_ADAPTIVE_RELAXED","TaoADMMUpdateType","TAO_ADMM_",NULL};
 25: /*@C
 26:   TaoInitializePackage - This function sets up PETSc to use the Tao
 27:   package.  When using static or shared libraries, this function is called from the
 28:   first entry to TaoCreate(); when using shared or static libraries, it is called
 29:   from PetscDLLibraryRegister_tao()

 31:   Level: developer

 33: .seealso: TaoCreate()
 34: @*/
 35: PetscErrorCode TaoInitializePackage(void)
 36: {
 37:   char           logList[256];
 38:   PetscBool      opt,pkg;


 43:   if (TaoPackageInitialized) return(0);
 44:   TaoPackageInitialized = PETSC_TRUE;
 45:   /* Register Classes */
 46:   PetscClassIdRegister("Tao",&TAO_CLASSID);
 47:   /* Register Constructors */
 48:   TaoRegisterAll();
 49:   /* Register Events */
 50:   PetscLogEventRegister("TaoSolve",         TAO_CLASSID,&TAO_Solve);
 51:   PetscLogEventRegister("TaoObjectiveEval", TAO_CLASSID,&TAO_ObjectiveEval);
 52:   PetscLogEventRegister("TaoGradientEval",  TAO_CLASSID,&TAO_GradientEval);
 53:   PetscLogEventRegister("TaoObjGradEval",   TAO_CLASSID,&TAO_ObjGradEval);
 54:   PetscLogEventRegister("TaoHessianEval",   TAO_CLASSID,&TAO_HessianEval);
 55:   PetscLogEventRegister("TaoConstrEval",    TAO_CLASSID,&TAO_ConstraintsEval);
 56:   PetscLogEventRegister("TaoJacobianEval",  TAO_CLASSID,&TAO_JacobianEval);
 57:   /* Process Info */
 58:   {
 59:     PetscClassId  classids[1];

 61:     classids[0] = TAO_CLASSID;
 62:     PetscInfoProcessClass("tao", 1, classids);
 63:   }
 64:   /* Process summary exclusions */
 65:   PetscOptionsGetString(NULL,NULL,"-log_exclude",logList,sizeof(logList),&opt);
 66:   if (opt) {
 67:     PetscStrInList("tao",logList,',',&pkg);
 68:     if (pkg) {PetscLogEventExcludeClass(TAO_CLASSID);}
 69:   }
 70:   /* Register package finalizer */
 71:   PetscRegisterFinalize(TaoFinalizePackage);
 72:   return(0);
 73: }

 75: #ifdef PETSC_USE_DYNAMIC_LIBRARIES
 76: /*
 77:   PetscDLLibraryRegister - this function is called when the dynamic library it
 78:   is in is opened.

 80:   This registers all of the Tao methods that are in the libtao
 81:   library.

 83:   Input Parameter:
 84: . path - library path
 85: */

 87: PETSC_EXTERN PetscErrorCode PetscDLLibraryRegister_tao(void)
 88: {

 92:     TaoInitializePackage();
 93:     TaoLineSearchInitializePackage();
 94:     return(0);
 95: }

 97: #endif /* PETSC_USE_DYNAMIC_LIBRARIES */