Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
253 changes: 123 additions & 130 deletions packages/rol/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,131 +1,124 @@
INCLUDE(TribitsPackageMacros)
INCLUDE(TribitsAddOptionAndDefine)


#
# A) Define the package
#

TRIBITS_PACKAGE(ROL)

#
# B) Set up package-specific options
#

TRIBITS_ADD_OPTION_AND_DEFINE(${PACKAGE_NAME}_ENABLE_DEBUG
HAVE_ROL_DEBUG
"Enable a host of runtime debug checking."
${${PROJECT_NAME}_ENABLE_DEBUG}
)

TRIBITS_ADD_OPTION_AND_DEFINE(${PACKAGE_NAME}_ENABLE_TIMERS
ROL_TIMERS
"Build ROL with Teuchos TimeMonitors enabled."
OFF
)

TRIBITS_ADD_OPTION_AND_DEFINE(${PACKAGE_NAME}_ENABLE_PYROL
ENABLE_PYBIND11_PYROL
"Build ROL with PyROL interface."
OFF
)

TRIBITS_ADD_OPTION_AND_DEFINE(${PACKAGE_NAME}_ENABLE_PARAMETERLIST_VALIDATION
ENABLE_PARAMETERLIST_VALIDATION
"Build ROL with ParameterList validation."
OFF
# Rapid Optimization Library

if( COMMAND TRIBITS_PACKAGE )
set( STANDALONE_ROL FALSE )
else()
set( STANDALONE_ROL TRUE )
endif()

if( STANDALONE_ROL )

cmake_minimum_required(VERSION 3.23)

set(CMAKE_POSITION_INDEPENDENT_CODE ON)

project( ROL
VERSION 2.0
DESCRIPTION "Rapid Optimization Library"
LANGUAGES CXX )
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake ${CMAKE_MODULE_PATH})

find_package(BLAS REQUIRED)
find_package(LAPACK REQUIRED)

if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE RELEASE CACHE STRING "Build type" FORCE)
endif()

# Set F77_BLAS_MANGLE macro based on Fortran-C interface (similar to Kokkos Kernels)
if("${F77_BLAS_MANGLE}" STREQUAL "")
enable_language(C)
enable_language(Fortran)
include(FortranCInterface)
FortranCInterface_HEADER(${CMAKE_CURRENT_BINARY_DIR}/FortranCInterface.h MACRO_NAMESPACE "F77_")
if(FortranCInterface_GLOBAL_SUFFIX STREQUAL "")
set(F77_BLAS_MANGLE "(name,NAME) ${FortranCInterface_GLOBAL_PREFIX}name")
else()
set(F77_BLAS_MANGLE "(name,NAME) ${FortranCInterface_GLOBAL_PREFIX}name ## ${FortranCInterface_GLOBAL_SUFFIX}")
endif()
message(STATUS "Detected Fortran name mangling: ${F77_BLAS_MANGLE}")
endif()

# Add pugixml for XML parameter file support
include(FetchContent)
FetchContent_Declare(
pugixml
GIT_REPOSITORY https://github.com/zeux/pugixml.git
GIT_TAG v1.14
)

# Build Options
SET( CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
INCLUDE(BuildOptions)
GET_PROPERTY( STACKTRACE_STRING GLOBAL PROPERTY STACKTRACE_IMPL )
#IF( ${STACKTRACE_STRING} STREQUAL "backward-cpp" )
#INCLUDE(BackwardConfig)
#ENDIF()


include(ROLParameters)


#
# C) Add the libraries, tests, and examples
#

ADD_SUBDIRECTORY(src)

IF( ROL_ENABLE_Sacado )
ADD_SUBDIRECTORY(adapters/sacado)
ENDIF()

IF (ROL_ENABLE_ArrayFireCPU)
ADD_SUBDIRECTORY(adapters/arrayfire)
ENDIF()

IF( ROL_ENABLE_PYROL )
ADD_SUBDIRECTORY(pyrol)
ENDIF()

# Adapters which require use of Teuchos

#GET_PROPERTY( PTR_STRING GLOBAL PROPERTY PTR_IMPL )
#GET_PROPERTY( PARAMETERLIST_STRING GLOBAL PROPERTY PARAMETERLIST_IMPL )
#IF( PTR_STRING STREQUAL "Teuchos::RCP" )
#IF( PARAMETERLIST_STRING STREQUAL "Teuchos::ParameterList" )

IF( ${USING_TEUCHOS_ALL} )


ADD_SUBDIRECTORY(adapters/teuchos)

IF( TPL_ENABLE_MPI )
ADD_SUBDIRECTORY(adapters/mpi)
ENDIF()

IF( ROL_ENABLE_Epetra )
ADD_SUBDIRECTORY(adapters/epetra)
ENDIF()

IF( ROL_ENABLE_Tpetra )
ADD_SUBDIRECTORY(adapters/tpetra)
ENDIF()

IF( ROL_ENABLE_Belos )
ADD_SUBDIRECTORY(adapters/belos)
ENDIF()

IF( ROL_ENABLE_Thyra )
ADD_SUBDIRECTORY(adapters/thyra)
ENDIF()

IF( ROL_ENABLE_TriKota )
ADD_SUBDIRECTORY(adapters/trikota)
ENDIF()

IF( ROL_ENABLE_pebbl )
ADD_SUBDIRECTORY(adapters/pebbl)
ENDIF()

IF (ROL_ENABLE_Boost AND ROL_ENABLE_MiniTensor)
ADD_SUBDIRECTORY(adapters/minitensor)
ENDIF()

ENDIF( ${USING_TEUCHOS_ALL} )

#ENDIF( PARAMETERLIST_STRING STREQUAL "Teuchos::ParameterList" )
#ENDIF( PTR_STRING STREQUAL "Teuchos::RCP" )

IF (ROL_ENABLE_Eigen)
ADD_SUBDIRECTORY(adapters/eigen)
ENDIF()


TRIBITS_ADD_TEST_DIRECTORIES(test)
TRIBITS_ADD_EXAMPLE_DIRECTORIES(example)
TRIBITS_ADD_EXAMPLE_DIRECTORIES(tutorial)

#
# D) Do standard postprocessing
#

TRIBITS_PACKAGE_POSTPROCESS()
FetchContent_MakeAvailable(pugixml)

include(ROLUtils)

# Configure the config header
configure_file("${PROJECT_SOURCE_DIR}/cmake/ROL_config.h.in" ROL_config.h @ONLY)

add_library(rol SHARED)

set(SRC ${PROJECT_SOURCE_DIR}/src)

# Set up compatibility includes (specific directories to avoid conflicts)
set(ROL_COMPATIBILITY_INCLUDES ${SRC}/compatibility/teuchos/blas
${SRC}/compatibility/teuchos/la
${SRC}/compatibility/simple/lapack
${SRC}/compatibility/simple/mpi
${SRC}/compatibility/simple/parameterlist
${SRC}/compatibility/std/shared_ptr
${SRC}/compatibility/teuchos/stacktrace
${SRC}/compatibility/teuchos-lite)

add_library(Teuchos_BLAS OBJECT ${SRC}/compatibility/teuchos-lite/Teuchos_BLAS.cpp)
add_library(Teuchos_CompObject OBJECT ${SRC}/compatibility/teuchos-lite/Teuchos_CompObject.cpp)
add_library(Teuchos_TestForException OBJECT ${SRC}/compatibility/teuchos-lite/Teuchos_TestForException.cpp)

# Use GLOB_RECURSE to find all directories in core components
set(ROL_CORE_DIRS ${SRC}/algorithm
${SRC}/elementwise
${SRC}/function
${SRC}/oed
${SRC}/sol
${SRC}/status
${SRC}/step
${SRC}/utils
${SRC}/vector
${SRC}/zoo)

set(ROL_CORE_INCLUDES)
foreach(core_dir ${ROL_CORE_DIRS})
file(GLOB_RECURSE subdirs LIST_DIRECTORIES true "${core_dir}/*")
list(APPEND ROL_CORE_INCLUDES ${core_dir})
foreach(subdir ${subdirs})
if(IS_DIRECTORY ${subdir})
list(APPEND ROL_CORE_INCLUDES ${subdir})
endif()
endforeach()
endforeach()

target_include_directories(rol PUBLIC ${CMAKE_CURRENT_BINARY_DIR}
${ROL_COMPATIBILITY_INCLUDES}
${ROL_CORE_INCLUDES})

target_link_libraries(rol PUBLIC ${BLAS_LIBRARIES} ${LAPACK_LIBRARIES}
pugixml
Teuchos_BLAS Teuchos_CompObject Teuchos_TestForException)

add_library(rol::rol ALIAS rol)

option(ENABLE_TESTS OFF)
option(ENABLE_EXAMPLES OFF)

if(ENABLE_TESTS)
enable_testing()
add_subdirectory(test)
endif()

if(ENABLE_EXAMPLES)
add_subdirectory(example)
endif()

else() # Build with Trilinos
include(cmake/TrilinosROL.cmake)
endif()
13 changes: 7 additions & 6 deletions packages/rol/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Rapid Optimization Library (ROL) Package
# Rapid Optimization Library (ROL)

![Rapid Optimization Library](rol.png)
![Rapid Optimization Library](https://raw.githubusercontent.com/sandialabs/rol/refs/heads/develop/rol.png)

**ROL** (as in rock and _roll_) is a high-performance C++ library for numerical optimization.
ROL brings an extensive collection of state-of-the-art optimization algorithms to virtually
Expand All @@ -20,16 +20,17 @@ Feature highlights:
4. Fast and robust algorithms for nonsmooth optimization
5. Trust-region methods for inexact and adaptive computations
6. PDE-OPT application development kit for PDE-constrained optimization
7. Interfaces and algorithms for optimal experimental design


## Copyright and License
See rol/COPYRIGHT, rol/LICENSE, https://trilinos.github.io/license.html and individual file headers for additional information.
See COPYRIGHT and LICENSE.


## Questions?
Contact lead developers:
## Questions?
Contact team or developers:

* ROL team (GitHub handle: @trilinos/rol)
* ROL Team (GitHub handle: @sandialabs/rol)
* Drew Kouri (GitHub handle: [dpkouri](https://github.com/dpkouri) or [email protected])
* Denis Ridzal (GitHub handle: [dridzal](https://github.com/dridzal) or [email protected])

4 changes: 2 additions & 2 deletions packages/rol/adapters/arrayfire/test/vector/test_01.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
#include "ROL_StdVector.hpp"
#include "ROL_Types.hpp"
#include "ROL_Stream.hpp"
#include "Teuchos_GlobalMPISession.hpp"
#include "ROL_GlobalMPISession.hpp"

#include <iostream>

Expand All @@ -24,7 +24,7 @@ typedef float ElementT;

int main(int argc, char *argv[]) {

Teuchos::GlobalMPISession mpiSession(&argc, &argv);
ROL::GlobalMPISession mpiSession(&argc, &argv);

// This little trick lets us print to std::cout only if a (dummy) command-line argument is provided.
int iprint = argc - 1;
Expand Down
4 changes: 2 additions & 2 deletions packages/rol/adapters/belos/test/vector/test_01.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
#include "ROL_StatusTest.hpp"

#include "ROL_Stream.hpp"
#include "Teuchos_GlobalMPISession.hpp"
#include "ROL_GlobalMPISession.hpp"
#include "Teuchos_XMLParameterListHelpers.hpp"

#include <cstdlib>
Expand All @@ -29,7 +29,7 @@ typedef double RealT;

int main(int argc, char *argv[]) {

Teuchos::GlobalMPISession mpiSession(&argc, &argv,0);
ROL::GlobalMPISession mpiSession(&argc, &argv,0);

// This little trick lets us print to std::cout only if a (dummy) command-line argument is provided.
int iprint = argc - 1;
Expand Down
4 changes: 2 additions & 2 deletions packages/rol/adapters/eigen/test/vector/test_01.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
#include "ROL_RandomVector.hpp"
#include "ROL_StdVector.hpp"
#include "ROL_Stream.hpp"
#include "Teuchos_GlobalMPISession.hpp"
#include "ROL_GlobalMPISession.hpp"

#include <iostream>

Expand All @@ -26,7 +26,7 @@ int main(int argc, char *argv[]) {
using E3V = ROL::Eigen3Vector<RealT>;
using EigenVector = Eigen::Matrix<RealT,Eigen::Dynamic,1>;

Teuchos::GlobalMPISession mpiSession(&argc, &argv);
ROL::GlobalMPISession mpiSession(&argc, &argv);

// This little trick lets us print to std::cout only if a (dummy) command-line argument is provided.
int iprint = argc - 1;
Expand Down
2 changes: 1 addition & 1 deletion packages/rol/adapters/epetra/test/sol/test_01.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ void printSolution(const std::vector<RealT> &x,
int main(int argc, char* argv[]) {
ROL::Ptr<Epetra_Comm> comm;
#ifdef HAVE_MPI
Teuchos::GlobalMPISession mpiSession(&argc, &argv,0);
ROL::GlobalMPISession mpiSession(&argc, &argv,0);
comm = ROL::makePtr<Epetra_MpiComm>(MPI_COMM_WORLD);
#else
comm = ROL::makePtr<Epetra_SerialComm>();
Expand Down
3 changes: 2 additions & 1 deletion packages/rol/adapters/epetra/test/sol/test_02.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include "Teuchos_ParameterList.hpp"
#include "Teuchos_XMLParameterListHelpers.hpp"
#include "ROL_Stream.hpp"
#include "ROL_GlobalMPISession.hpp"

#ifdef HAVE_MPI
#include "Epetra_MpiComm.h"
Expand All @@ -26,7 +27,7 @@ typedef double RealT;
int main(int argc, char* argv[]) {
ROL::Ptr<Epetra_Comm> comm;
#ifdef HAVE_MPI
Teuchos::GlobalMPISession mpiSession(&argc, &argv,0);
ROL::GlobalMPISession mpiSession(&argc, &argv,0);
comm = ROL::makePtr<Epetra_MpiComm>(MPI_COMM_WORLD);
#else
comm = ROL::makePtr<Epetra_SerialComm>();
Expand Down
4 changes: 2 additions & 2 deletions packages/rol/adapters/epetra/test/vector/test_01.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
#include "ROL_Types.hpp"
#include "Epetra_Map.h"
#include "ROL_Stream.hpp"
#include "Teuchos_GlobalMPISession.hpp"
#include "ROL_GlobalMPISession.hpp"
#ifdef HAVE_MPI
#include "Epetra_MpiComm.h"
#else
Expand All @@ -30,7 +30,7 @@ typedef double ElementT;
int main(int argc, char *argv[]) {

#ifdef HAVE_MPI
Teuchos::GlobalMPISession mpiSession(&argc, &argv,0);
ROL::GlobalMPISession mpiSession(&argc, &argv,0);
Epetra_MpiComm Comm(MPI_COMM_WORLD);
#else
Epetra_SerialComm Comm;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
#include <vector>
#include <mpi.h>

#include "Teuchos_GlobalMPISession.hpp"
#include "ROL_GlobalMPISession.hpp"

#include "ROL_TimeStamp.hpp"
#include "ROL_PinTCommunicators.hpp"
Expand Down
Loading
Loading