Date: 2022-03-04T17:39:48+00:00

Actual source code: dlregistao.c

      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: const char *const TaoALMMTypes[]            = {"CLASSIC","PHR","TaoALMMType","TAO_ALMM_",NULL};
     26: /*@C
     27:   TaoInitializePackage - This function sets up PETSc to use the Tao
     28:   package.  When using static or shared libraries, this function is called from the
     29:   first entry to TaoCreate(); when using shared or static libraries, it is called
     30:   from PetscDLLibraryRegister_tao()

     32:   Level: developer

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

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

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

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

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

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

     88: PETSC_EXTERN PetscErrorCode PetscDLLibraryRegister_petsctao(void)
     89: {

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

     98: #endif /* PETSC_HAVE_DYNAMIC_LIBRARIES */