Skip to content
Merged
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
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,9 @@
- Added IDA option to choose the consistent initial condition calculation type.
- Implemented `tagDifferentiable()` for `PowerElectronics` models.
- Fixed the `TenGenGenrou` example to output the correct omega values.
- Added `GridKit_ENABLE_DEVELOPER_MODE` CMake option; in developer mode the Logger defaults to `EVERYTHING` verbosity.
- Added `Logger::raiseVerbosity()`, which raises the verbosity without lowering a higher level.
- Changed most of the core library code outputs to use the Logger instead of `std::cout`/`std::cerr`.

## v0.1

Expand Down
8 changes: 6 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,14 @@ option(GridKit_ENABLE_UBSAN "Enable the undefined behavior sanitizer" OFF)
option(GridKit_ENABLE_OPENMP "Enable OpenMP" OFF)

# Enable Threads
option(GridKit_ENABLE_THREADS "Enable THreads" OFF)
option(GridKit_ENABLE_THREADS "Enable Threads" OFF)

# ZeroMQ support is disabled by default
option(GridKit_ENABLE_ZMQ "Enable ZeroMQ support" OFF)

# Developer mode (including more verbose outputs) disabled by default
option(GridKit_ENABLE_DEVELOPER_MODE "Enable developer mode" OFF)

# This allows use of "GRIDKIT_*" versions of the above options
list(
APPEND
Expand All @@ -63,7 +66,8 @@ list(
UBSAN
OPENMP
THREADS
ZMQ)
ZMQ
DEVELOPER_MODE)
foreach(_opt IN LISTS _gridkit_enable_options)
if(NOT DEFINED GRIDKIT_ENABLE_${_opt})
set(GRIDKIT_ENABLE_${_opt} ${GridKit_ENABLE_${_opt}})
Expand Down
1 change: 1 addition & 0 deletions GridKit/Definitions.hpp.in
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#cmakedefine GRIDKIT_ENABLE_OPENMP
#cmakedefine GRIDKIT_ENABLE_THREADS
#cmakedefine GRIDKIT_ENABLE_SUNDIALS_SPARSE
#cmakedefine GRIDKIT_ENABLE_DEVELOPER_MODE

#define GRIDKIT_VERSION "@GridKit_VERSION@"

Expand Down
46 changes: 25 additions & 21 deletions GridKit/LinearAlgebra/SparseMatrix/CooMatrix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,14 @@
#include <iomanip>
#include <limits>

#include <GridKit/Utilities/Logger/Logger.hpp>

namespace GridKit
{
namespace LinearAlgebra
{
using Log = ::GridKit::Utilities::Logger;

template <typename RealT, typename IdxT>
CooMatrix<RealT, IdxT>::CooMatrix()
{
Expand Down Expand Up @@ -102,8 +106,8 @@ namespace GridKit
// Set device data to null
if (d_row_data_ || d_col_data_ || d_val_data_)
{
std::cerr << "Device data unexpectedly allocated. "
<< "Possible bug in matrix::Sparse class.\n";
Log::error() << "Device data unexpectedly allocated. "
<< "Possible bug in matrix::Sparse class.\n";
}
d_row_data_ = nullptr;
d_col_data_ = nullptr;
Expand Down Expand Up @@ -156,8 +160,8 @@ namespace GridKit
// Set host data to null
if (h_row_data_ || h_col_data_ || h_val_data_)
{
std::cerr << "Host data unexpectedly allocated. "
<< "Possible bug in matrix::Sparse class.\n";
Log::error() << "Host data unexpectedly allocated. "
<< "Possible bug in matrix::Sparse class.\n";
}
h_row_data_ = nullptr;
h_col_data_ = nullptr;
Expand All @@ -171,8 +175,8 @@ namespace GridKit
*vals = nullptr;
break;
default:
std::cerr << "CooMatrix constructor failed! "
<< "Possible bug in memory spaces setting.\n";
Log::error() << "CooMatrix constructor failed! "
<< "Possible bug in memory spaces setting.\n";
break;
}
}
Expand Down Expand Up @@ -258,14 +262,14 @@ namespace GridKit
case HOST:
if (owns_cpu_sparsity_pattern_ && (h_row_data_ || h_col_data_))
{
std::cerr << "Trying to set matrix host data, but the data already set!\n";
std::cerr << "Ignoring setDataPointers function call ...\n";
Log::warning() << "Trying to set matrix host data, but the data already set! "
<< "Ignoring setDataPointers function call.\n";
return 1;
}
if (owns_cpu_values_ && h_val_data_)
{
std::cerr << "Trying to set matrix host values, but the values already set!\n";
std::cerr << "Ignoring setValuesPointer function call ...\n";
Log::warning() << "Trying to set matrix host values, but the values already set! "
<< "Ignoring setValuesPointer function call.\n";
return 1;
}
h_row_data_ = row_data;
Expand All @@ -278,14 +282,14 @@ namespace GridKit
case DEVICE:
if (owns_gpu_sparsity_pattern_ && (d_row_data_ || d_col_data_))
{
std::cerr << "Trying to set matrix host data, but the data already set!\n";
std::cerr << "Ignoring setDataPointers function call ...\n";
Log::warning() << "Trying to set matrix host data, but the data already set! "
<< "Ignoring setDataPointers function call.\n";
return 1;
}
if (owns_gpu_values_ && d_val_data_)
{
std::cerr << "Trying to set matrix device values, but the values already set!\n";
std::cerr << "Ignoring setValuesPointer function call ...\n";
Log::warning() << "Trying to set matrix device values, but the values already set! "
<< "Ignoring setValuesPointer function call.\n";
return 1;
}
d_row_data_ = row_data;
Expand Down Expand Up @@ -360,7 +364,7 @@ namespace GridKit
{
if (!h_data_updated_)
{
std::cerr << "CooMatrix::getCsrRowData requires up-to-date host data, but host is out of date!\n";
Log::error() << "CooMatrix::getCsrRowData requires up-to-date host data, but host is out of date!\n";
assert(h_data_updated_);
return nullptr;
}
Expand Down Expand Up @@ -524,14 +528,14 @@ namespace GridKit

if (h_data_updated_)
{
std::cerr << "CooMatrix::syncData is trying to sync host, but host already up to date!\n";
Log::warning() << "CooMatrix::syncData is trying to sync host, but host already up to date!\n";
assert(!h_data_updated_);
return 1;
}
if (!d_data_updated_)
{
std::cerr << "CooMatrix::syncData is trying to sync host with device, but device is out of date!\n"
<< "See CooMatrix::syncData documentation\n.";
Log::error() << "CooMatrix::syncData is trying to sync host with device, but device is out of date! "
<< "See CooMatrix::syncData documentation.\n";
assert(d_data_updated_);
}
if ((h_row_data_ == nullptr) && (h_col_data_ == nullptr))
Expand All @@ -555,14 +559,14 @@ namespace GridKit

if (d_data_updated_)
{
std::cerr << "CooMatrix::syncData is trying to sync device, but device already up to date!\n";
Log::warning() << "CooMatrix::syncData is trying to sync device, but device already up to date!\n";
assert(!d_data_updated_);
return 1;
}
if (!h_data_updated_)
{
std::cerr << "CooMatrix::syncData is trying to sync device with host, but host is out of date!\n"
<< "See CooMatrix::syncData documentation\n.";
Log::error() << "CooMatrix::syncData is trying to sync device with host, but host is out of date! "
<< "See CooMatrix::syncData documentation.\n";
assert(h_data_updated_);
}
if ((d_row_data_ == nullptr) && (d_col_data_ == nullptr))
Expand Down
52 changes: 28 additions & 24 deletions GridKit/LinearAlgebra/SparseMatrix/CsrMatrix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,14 @@
#include <iomanip>
#include <limits>

#include <GridKit/Utilities/Logger/Logger.hpp>

namespace GridKit
{
namespace LinearAlgebra
{
using Log = ::GridKit::Utilities::Logger;

template <typename RealT, typename IdxT>
CsrMatrix<RealT, IdxT>::CsrMatrix()
{
Expand Down Expand Up @@ -100,8 +104,8 @@ namespace GridKit
// Set device data to null
if (d_row_data_ || d_col_data_ || d_val_data_)
{
std::cerr << "Device data unexpectedly allocated. "
<< "Possible bug in matrix::Sparse class.\n";
Log::error() << "Device data unexpectedly allocated. "
<< "Possible bug in matrix::Sparse class.\n";
}
d_row_data_ = nullptr;
d_col_data_ = nullptr;
Expand Down Expand Up @@ -154,8 +158,8 @@ namespace GridKit
// Set host data to null
if (h_row_data_ || h_col_data_ || h_val_data_)
{
std::cerr << "Host data unexpectedly allocated. "
<< "Possible bug in matrix::Sparse class.\n";
Log::error() << "Host data unexpectedly allocated. "
<< "Possible bug in matrix::Sparse class.\n";
}
h_row_data_ = nullptr;
h_col_data_ = nullptr;
Expand All @@ -169,8 +173,8 @@ namespace GridKit
*vals = nullptr;
break;
default:
std::cerr << "CsrMatrix constructor failed! "
<< "Possible bug in memory spaces setting.\n";
Log::error() << "CsrMatrix constructor failed! "
<< "Possible bug in memory spaces setting.\n";
break;
}
}
Expand Down Expand Up @@ -302,14 +306,14 @@ namespace GridKit
case HOST:
if (owns_cpu_sparsity_pattern_ && (h_row_data_ || h_col_data_))
{
std::cerr << "Trying to set matrix host data, but the data already set!\n";
std::cerr << "Ignoring setDataPointers function call ...\n";
Log::warning() << "Trying to set matrix host data, but the data already set! "
<< "Ignoring setDataPointers function call.\n";
return 1;
}
if (owns_cpu_values_ && h_val_data_)
{
std::cerr << "Trying to set matrix host values, but the values already set!\n";
std::cerr << "Ignoring setValuesPointer function call ...\n";
Log::warning() << "Trying to set matrix host values, but the values already set! "
<< "Ignoring setValuesPointer function call.\n";
return 1;
}
h_row_data_ = row_data;
Expand All @@ -322,14 +326,14 @@ namespace GridKit
case DEVICE:
if (owns_gpu_sparsity_pattern_ && (d_row_data_ || d_col_data_))
{
std::cerr << "Trying to set matrix host data, but the data already set!\n";
std::cerr << "Ignoring setDataPointers function call ...\n";
Log::warning() << "Trying to set matrix host data, but the data already set! "
<< "Ignoring setDataPointers function call.\n";
return 1;
}
if (owns_gpu_values_ && d_val_data_)
{
std::cerr << "Trying to set matrix device values, but the values already set!\n";
std::cerr << "Ignoring setValuesPointer function call ...\n";
Log::warning() << "Trying to set matrix device values, but the values already set! "
<< "Ignoring setValuesPointer function call.\n";
return 1;
}
d_row_data_ = row_data;
Expand Down Expand Up @@ -498,8 +502,8 @@ namespace GridKit
case HOST:
if (owns_cpu_values_ && h_val_data_)
{
std::cerr << "Trying to set matrix host values, but the values already set!\n";
std::cerr << "Ignoring setValuesPointer function call ...\n";
Log::warning() << "Trying to set matrix host values, but the values already set! "
<< "Ignoring setValuesPointer function call.\n";
return 1;
}
h_val_data_ = new_vals;
Expand All @@ -509,8 +513,8 @@ namespace GridKit
case DEVICE:
if (owns_gpu_values_ && d_val_data_)
{
std::cerr << "Trying to set matrix device values, but the values already set!\n";
std::cerr << "Ignoring setValuesPointer function call ...\n";
Log::warning() << "Trying to set matrix device values, but the values already set! "
<< "Ignoring setValuesPointer function call.\n";
return 1;
}
d_val_data_ = new_vals;
Expand Down Expand Up @@ -736,14 +740,14 @@ namespace GridKit

if (h_data_updated_)
{
std::cerr << "CsrMatrix::syncData is trying to sync host, but host already up to date!\n";
Log::warning() << "CsrMatrix::syncData is trying to sync host, but host already up to date!\n";
assert(!h_data_updated_);
return 1;
}
if (!d_data_updated_)
{
std::cerr << "CsrMatrix::syncData is trying to sync host with device, but device is out of date!\n"
<< "See CsrMatrix::syncData documentation\n.";
Log::error() << "CsrMatrix::syncData is trying to sync host with device, but device is out of date! "
<< "See CsrMatrix::syncData documentation.\n";
assert(d_data_updated_);
}
if ((h_row_data_ == nullptr) && (h_col_data_ == nullptr))
Expand All @@ -767,14 +771,14 @@ namespace GridKit

if (d_data_updated_)
{
std::cerr << "CsrMatrix::syncData is trying to sync device, but device already up to date!\n";
Log::warning() << "CsrMatrix::syncData is trying to sync device, but device already up to date!\n";
assert(!d_data_updated_);
return 1;
}
if (!h_data_updated_)
{
std::cerr << "CsrMatrix::syncData is trying to sync device with host, but host is out of date!\n"
<< "See CsrMatrix::syncData documentation\n.";
Log::error() << "CsrMatrix::syncData is trying to sync device with host, but host is out of date! "
<< "See CsrMatrix::syncData documentation.\n";
assert(h_data_updated_);
}
if ((d_row_data_ == nullptr) && (d_col_data_ == nullptr))
Expand Down
Loading
Loading