Skip to content

Commit

Permalink
Fix compiler warning and error when including ambit. (#59)
Browse files Browse the repository at this point in the history
  • Loading branch information
JonathonMisiewicz authored Aug 21, 2023
1 parent bda0f02 commit de15400
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 12 deletions.
5 changes: 5 additions & 0 deletions cmake/FindTargetHDF5.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,11 @@ else()
endif()
endif()

if (${PN}_VERSION MATCHES "^([0-9]+).([0-9]+).*$")
set(${PN}_VERSION_Mm "${CMAKE_MATCH_1}.${CMAKE_MATCH_2}")
endif()


get_property(_ill TARGET tgt::hdf5 PROPERTY INTERFACE_LINK_LIBRARIES)
get_property(_iid TARGET tgt::hdf5 PROPERTY INTERFACE_INCLUDE_DIRECTORIES)
set(${PN}_MESSAGE "Found HDF5: ${_ill} (found version ${${PN}_VERSION})")
Expand Down
2 changes: 1 addition & 1 deletion cmake/ambitConfig.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR})
# check library dependency available
include(CMakeFindDependencyMacro)
if(NOT TARGET tgt::hdf5)
find_dependency(TargetHDF5 @TargetHDF5_VERSION@ EXACT)
find_dependency(TargetHDF5 @TargetHDF5_VERSION_Mm@)
endif()
if(NOT TARGET tgt::lapack)
find_dependency(TargetLAPACK)
Expand Down
4 changes: 2 additions & 2 deletions include/ambit/print.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,12 @@ namespace ambit
{

/// Print function. Only the master node is allowed to print to the screen.
void print(const string &format, ...);
void print(const string format, ...);

/** Each process will print to their respective output file.
* The master process will print to both the screen and its output file.
*/
void printn(const string &format, ...);
void printn(const string format, ...);

/** Increases printing column offset by increment.
* @param increment the amount to increase indentation.
Expand Down
4 changes: 2 additions & 2 deletions src/tensor/print.cc
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ void unindent(int decrement)
indent_size = 0;
}

void print(const string &format, ...)
void print(const string format, ...)
{
if (ambit::settings::rank == 0)
{
Expand All @@ -67,7 +67,7 @@ void print(const string &format, ...)
}
}

void printn(const string &format, ...)
void printn(const string format, ...)
{
for (int proc = 0; proc < settings::nprocess; proc++)
{
Expand Down
3 changes: 2 additions & 1 deletion src/tensor/sliced_tensor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,13 @@ SlicedTensor::SlicedTensor(Tensor T, const IndexRange &range, double factor)

void SlicedTensor::operator=(const SlicedTensor &rhs)
{
if (T() == rhs.T())
if (T() == rhs.T()) {
if (range_ == rhs.range_ and factor_ == rhs.factor_) {
return; // No work to do.
} else {
throw std::runtime_error("Non-trivial self-assignment is not allowed.");
}
}
if (T_.rank() != rhs.T().rank())
throw std::runtime_error("Sliced tensors do not have same rank");
T_.slice(rhs.T(), range_, rhs.range_, rhs.factor_, 0.0);
Expand Down
10 changes: 4 additions & 6 deletions src/tensor/timer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -109,13 +109,11 @@ void print_timer_info(TimerDetail *timer)
char buffer[512];
if (timer != root)
{
auto time = std::chrono::duration_cast<std::chrono::milliseconds>(timer->total_time).count();
snprintf(buffer, 512, "%lld ms : %lld calls : %lld ms per call : ",
std::chrono::duration_cast<std::chrono::milliseconds>(
timer->total_time),
timer->total_calls,
std::chrono::duration_cast<std::chrono::milliseconds>(
timer->total_time) /
timer->total_calls);
time,
static_cast<long long>(timer->total_calls),
time / timer->total_calls);
print("%s%*s%s\n", buffer,
// 60 - ambit::current_indent() - strlen(buffer),
60 - strlen(buffer), "", timer->name.c_str());
Expand Down

0 comments on commit de15400

Please sign in to comment.