Date: 2022-03-31T04:48:57+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: {
     15:   PetscFunctionListDestroy(&TaoList);
     16:   TaoPackageInitialized = PETSC_FALSE;
     17:   return 0;
     18: }

     20: /*@C
     21:   TaoInitializePackage - This function sets up PETSc to use the Tao
     22:   package.  When using static or shared libraries, this function is called from the
     23:   first entry to TaoCreate(); when using shared or static libraries, it is called
     24:   from PetscDLLibraryRegister_tao()

     26:   Level: developer

     28: .seealso: TaoCreate()
     29: @*/
     30: PetscErrorCode TaoInitializePackage(void)
     31: {
     32:   char           logList[256];
     33:   PetscBool      opt,pkg;

     35:   if (TaoPackageInitialized) return 0;
     36:   TaoPackageInitialized = PETSC_TRUE;
     37:   /* Register Classes */
     38:   PetscClassIdRegister("Tao",&TAO_CLASSID);
     39:   /* Register Constructors */
     40:   TaoRegisterAll();
     41:   /* Register Events */
     42:   PetscLogEventRegister("TaoSolve",         TAO_CLASSID,&TAO_Solve);
     43:   PetscLogEventRegister("TaoObjectiveEval", TAO_CLASSID,&TAO_ObjectiveEval);
     44:   PetscLogEventRegister("TaoGradientEval",  TAO_CLASSID,&TAO_GradientEval);
     45:   PetscLogEventRegister("TaoObjGradEval",   TAO_CLASSID,&TAO_ObjGradEval);
     46:   PetscLogEventRegister("TaoHessianEval",   TAO_CLASSID,&TAO_HessianEval);
     47:   PetscLogEventRegister("TaoConstrEval",    TAO_CLASSID,&TAO_ConstraintsEval);
     48:   PetscLogEventRegister("TaoJacobianEval",  TAO_CLASSID,&TAO_JacobianEval);
     49:   /* Process Info */
     50:   {
     51:     PetscClassId  classids[1];

     53:     classids[0] = TAO_CLASSID;
     54:     PetscInfoProcessClass("tao", 1, classids);
     55:   }
     56:   /* Process summary exclusions */
     57:   PetscOptionsGetString(NULL,NULL,"-log_exclude",logList,sizeof(logList),&opt);
     58:   if (opt) {
     59:     PetscStrInList("tao",logList,',',&pkg);
     60:     if (pkg) PetscLogEventExcludeClass(TAO_CLASSID);
     61:   }
     62:   /* Register package finalizer */
     63:   PetscRegisterFinalize(TaoFinalizePackage);
     64:   return 0;
     65: }

     67: #if defined(PETSC_HAVE_DYNAMIC_LIBRARIES)
     68: /*
     69:   PetscDLLibraryRegister - this function is called when the dynamic library it
     70:   is in is opened.

     72:   This registers all of the Tao methods that are in the libtao
     73:   library.

     75:   Input Parameter:
     76: . path - library path
     77: */
     78: PETSC_EXTERN PetscErrorCode PetscDLLibraryRegister_petsctao(void)
     79: {
     80:   TaoInitializePackage();
     81:   TaoLineSearchInitializePackage();
     82:   return 0;
     83: }
     84: #endif /* PETSC_HAVE_DYNAMIC_LIBRARIES */