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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
345 changes: 232 additions & 113 deletions CMakeLists.txt

Large diffs are not rendered by default.

8 changes: 8 additions & 0 deletions SeQuant/core/context.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,14 @@

namespace sequant {

bool default_context_manipulation_threadsafe() {
#ifdef SEQUANT_CONTEXT_MANIPULATION_THREADSAFE
return true;
#else
return false;
#endif
}

bool operator==(const Context& ctx1, const Context& ctx2) {
if (&ctx1 == &ctx2)
return true;
Expand Down
8 changes: 1 addition & 7 deletions SeQuant/core/context.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -222,13 +222,7 @@ bool operator!=(const Context& ctx1, const Context& ctx2);
/// @{

/// \return whether context manipulation functions are thread-safe
inline constexpr bool default_context_manipulation_threadsafe() {
#ifdef SEQUANT_CONTEXT_MANIPULATION_THREADSAFE
return true;
#else
return false;
#endif
}
bool default_context_manipulation_threadsafe();

/// @brief access default Context for the given Statistics
/// @param s Statistics
Expand Down
6 changes: 3 additions & 3 deletions SeQuant/core/optimize.hpp → SeQuant/core/eval/optimize.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,7 @@ ExprPtr optimize(ExprPtr const& expr, IdxToSize const& idx2size,
} // namespace opt

///
/// Optimize the expression using IndexSpace::aproximate_size() for reference
/// Optimize the expression using IndexSpace::approximate_size() for reference
/// index extent.
///
/// \param expr Expression to be optimized.
Expand All @@ -398,7 +398,7 @@ ExprPtr optimize(ExprPtr const& expr, IdxToSize const& idx2size,
/// \return Optimized expression for lower evaluation cost.
ExprPtr optimize(ExprPtr const& expr, bool reorder_sum = true);

/// Optimize the expression using IndexSpace::aproximate_size() for reference
/// Optimize the expression using IndexSpace::approximate_size() for reference
/// index extent.
///
/// \param expr Expression to be optimized.
Expand All @@ -408,7 +408,7 @@ ExprPtr optimize(ExprPtr const& expr, bool reorder_sum = true);
/// \return Optimized expression for lower evaluation cost.
ResultExpr& optimize(ResultExpr& expr, bool reorder_sum = true);

/// Optimize the expression using IndexSpace::aproximate_size() for reference
/// Optimize the expression using IndexSpace::approximate_size() for reference
/// index extent.
///
/// \param expr Expression to be optimized.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include <SeQuant/core/optimize/fusion.hpp>
#include <SeQuant/core/eval/optimize/fusion.hpp>

#include <SeQuant/core/complex.hpp>
#include <SeQuant/core/container.hpp>
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@
#include <SeQuant/core/complex.hpp>
#include <SeQuant/core/container.hpp>
#include <SeQuant/core/eval/eval_expr.hpp>
#include <SeQuant/core/eval/eval_node.hpp>
#include <SeQuant/core/eval/optimize.hpp>
#include <SeQuant/core/expr.hpp>
#include <SeQuant/core/hash.hpp>
#include <SeQuant/core/optimize.hpp>
#include <SeQuant/core/utility/indices.hpp>
#include <SeQuant/core/utility/macros.hpp>

Expand Down
1 change: 0 additions & 1 deletion SeQuant/core/expressions/result_expr.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#include <SeQuant/core/expressions/result_expr.hpp>
#include <SeQuant/core/expressions/tensor.hpp>
#include <SeQuant/core/expressions/variable.hpp>
#include <SeQuant/core/optimize.hpp>
#include <SeQuant/core/utility/indices.hpp>

namespace sequant {
Expand Down
43 changes: 43 additions & 0 deletions SeQuant/core/utility/macros.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
//
// Created by Eduard Valeyev on 7/31/23
//

#include <SeQuant/core/utility/macros.hpp>

#include <cstdlib>
#include <iostream>
#include <sstream>

#define SEQUANT_ASSERT_BEHAVIOR \
SEQUANT_CONCAT(SEQUANT_ASSERT_, SEQUANT_ASSERT_BEHAVIOR_)

namespace sequant {

#ifdef SEQUANT_ASSERT_ENABLED
void assert_failed(const std::string &errmsg,
const std::source_location location) {
#if SEQUANT_ASSERT_BEHAVIOR == SEQUANT_ASSERT_THROW
std::ostringstream oss;
oss << errmsg << " at " << location.file_name() << ":" << location.line()
<< " in function '" << location.function_name() << "'";
throw sequant::Exception(oss.str());
#elif SEQUANT_ASSERT_BEHAVIOR == SEQUANT_ASSERT_ABORT
std::cerr << errmsg << " at " << location.file_name() << ":"
<< location.line() << " in function '" << location.function_name()
<< "'" << std::endl;
std::abort();
#endif
}
#else
void assert_failed(const std::string &, const std::source_location) {}
#endif

[[noreturn]] void abort_msg(const std::string &errmsg,
const std::source_location location) {
std::cerr << errmsg << " at " << location.file_name() << ":"
<< location.line() << " in function '" << location.function_name()
<< "'";
std::abort();
}

} // namespace sequant
42 changes: 6 additions & 36 deletions SeQuant/core/utility/macros.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,8 @@
#include <SeQuant/core/utility/exception.hpp>

#include <cstdlib>
#include <iostream>
#include <source_location>
#include <sstream>
#include <utility>
#include <string>

/* detect C++ compiler id:
- ids taken from CMake
Expand Down Expand Up @@ -71,38 +69,15 @@
#define SEQUANT_ASSERT_ABORT 3
#define SEQUANT_ASSERT_IGNORE 4
#define SEQUANT_STRINGIFY(x) #x
#define SEQUANT_ASSERT_BEHAVIOR \
SEQUANT_CONCAT(SEQUANT_ASSERT_, SEQUANT_ASSERT_BEHAVIOR_)
#if SEQUANT_ASSERT_BEHAVIOR != SEQUANT_ASSERT_IGNORE
#define SEQUANT_ASSERT_ENABLED
#endif

namespace sequant {

#ifdef SEQUANT_ASSERT_ENABLED
[[noreturn]]
#endif
inline void
assert_failed([[maybe_unused]] const std::string &errmsg,
[[maybe_unused]] const std::source_location location =
std::source_location::current()) {
#ifdef SEQUANT_ASSERT_ENABLED
#if SEQUANT_ASSERT_BEHAVIOR == SEQUANT_ASSERT_THROW
std::ostringstream oss;
oss
#elif SEQUANT_ASSERT_BEHAVIOR == SEQUANT_ASSERT_ABORT
std::cerr
#endif // SEQUANT_ASSERT_BEHAVIOR
<< errmsg << " at " << location.file_name() << ":" << location.line()
<< " in function '" << location.function_name() << "'";
#if SEQUANT_ASSERT_BEHAVIOR == SEQUANT_ASSERT_THROW
throw sequant::Exception(oss.str());
#elif SEQUANT_ASSERT_BEHAVIOR == SEQUANT_ASSERT_ABORT
std::cerr << std::endl;
std::abort();
#endif // SEQUANT_ASSERT_BEHAVIOR
#endif // SEQUANT_ASSERT_ENABLED
}
void assert_failed(
const std::string &errmsg,
std::source_location location = std::source_location::current());
} // namespace sequant

#ifdef SEQUANT_ASSERT_ENABLED
Expand All @@ -123,14 +98,9 @@ assert_failed([[maybe_unused]] const std::string &errmsg,
#endif

namespace sequant {
[[noreturn]] inline void abort_msg(
[[noreturn]] void abort_msg(
const std::string &errmsg,
const std::source_location location = std::source_location::current()) {
std::cerr << errmsg << " at " << location.file_name() << ":"
<< location.line() << " in function '" << location.function_name()
<< "'";
std::abort();
}
std::source_location location = std::source_location::current());
} // namespace sequant

#define SEQUANT_ABORT(msg) sequant::abort_msg(msg)
Expand Down
2 changes: 1 addition & 1 deletion SeQuant/domain/mbpt/spin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@

#include <SeQuant/core/algorithm.hpp>
#include <SeQuant/core/attr.hpp>
#include <SeQuant/core/eval/optimize.hpp>
#include <SeQuant/core/expr.hpp>
#include <SeQuant/core/math.hpp>
#include <SeQuant/core/optimize.hpp>
#include <SeQuant/core/rational.hpp>
#include <SeQuant/core/reserved.hpp>
#include <SeQuant/core/space.hpp>
Expand Down
22 changes: 19 additions & 3 deletions cmake/sequant-config.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,13 @@
#
# and the following imported targets
#
# SeQuant::SeQuant - the SeQuant library
# SeQuant::SeQuant - umbrella SeQuant target (links all modules)
# SeQuant::symb - symbolic core
# SeQuant::eval - evaluation framework
# SeQuant::optimize - expression optimization (STO, CSE, fusion)
# SeQuant::export - code generation/export
# SeQuant::core - version info + symb + eval + export
# SeQuant::mbpt - MBPT domain code
#

# Set package version
Expand Down Expand Up @@ -72,9 +78,19 @@ endif (NOT TARGET Threads::Threads)
# Include library IMPORT targets
if(NOT TARGET SeQuant::SeQuant)
include("${CMAKE_CURRENT_LIST_DIR}/sequant-targets.cmake")
if(NOT TARGET SeQuant::SeQuant)
message(FATAL_ERROR "expected SeQuant::SeQuant among imported SeQuant targets")
# Verify expected targets exist
set(grandTargetList symb eval optimize export core mbpt SeQuant)
if (SEQUANT_HAS_TILEDARRAY)
list(APPEND grandTargetList eval::ta)
endif()
if (SEQUANT_HAS_BTAS)
list(APPEND grandTargetList eval::btas)
endif()
foreach(_target ${grandTargetList})
if(NOT TARGET SeQuant::${_target})
message(FATAL_ERROR "expected SeQuant::${_target} among imported SeQuant targets")
endif()
endforeach()
endif()

set(SEQUANT_FOUND TRUE)
2 changes: 1 addition & 1 deletion doc/user/guide/operator.rst
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ only the non-zero contributions.

``mbpt::Operator`` is constructed from 3 callables (e.g., lambdas):

- ``void -> std::wstring_view``: returns the operator label such as "T" or "Λ"
- ``void -> std::wstring_view``: returns the operator label such as "t" or "λ"
- ``void -> ExptPtr``: returns the tensor form of the operator, and
- ``QuantumNumberChange<>& -> void``: encodes the action on the given input state by mutating its quantum numbers given as the argument to the lambda.

Expand Down
2 changes: 1 addition & 1 deletion tests/integration/eval/calc_info.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#include <SeQuant/core/container.hpp>
#include <SeQuant/core/eval/cache_manager.hpp>
#include <SeQuant/core/eval/eval_expr.hpp>
#include <SeQuant/core/optimize.hpp>
#include <SeQuant/core/eval/optimize.hpp>
#include <SeQuant/core/utility/macros.hpp>
#include <SeQuant/domain/mbpt/spin.hpp>

Expand Down
Loading