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
2 changes: 1 addition & 1 deletion VERSION.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.20260722.0
1.20260723.0
33 changes: 23 additions & 10 deletions src/api/libopencor/sedinstance.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,29 @@ class LIBOPENCOR_EXPORT SedInstance: public Logger
SedInstance &operator=(const SedInstance &pRhs) = delete; /**< No copy assignment operator allowed, @private. */
SedInstance &operator=(SedInstance &&pRhs) noexcept = delete; /**< No move assignment operator allowed, @private. */

/**
* @brief The status of an instance.
*
* The status of an instance, i.e. whether it is idle, running, or paused.
*/

enum class Status
{
IDLE, /**< The instance is idle. */
RUNNING, /**< The instance is currently running. */
PAUSED /**< The instance is currently paused. */
};

/**
* @brief Return the status of this instance.
*
* Return the status of this instance.
*
* @return The status of this instance.
*/

Status status() const noexcept;

/**
* @brief Run all the tasks associated with this instance.
*
Expand All @@ -63,16 +86,6 @@ class LIBOPENCOR_EXPORT SedInstance: public Logger

bool startRun();

/**
* @brief Return whether this instance is currently running.
*
* Return whether this instance is currently running.
*
* @return @c true if this instance is running, @c false otherwise.
*/

bool isRunning() const noexcept;

/**
* @brief Wait for any currently-running instance to complete.
*
Expand Down
15 changes: 14 additions & 1 deletion src/bindings/javascript/sed.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,11 +86,16 @@ void sedApi()

// SedInstance API.

emscripten::enum_<libOpenCOR::SedInstance::Status>("SedInstance.Status")
.value("IDLE", libOpenCOR::SedInstance::Status::IDLE)
.value("RUNNING", libOpenCOR::SedInstance::Status::RUNNING)
.value("PAUSED", libOpenCOR::SedInstance::Status::PAUSED);

emscripten::class_<libOpenCOR::SedInstance, emscripten::base<libOpenCOR::Logger>>("SedInstance")
.smart_ptr<libOpenCOR::SedInstancePtr>("SedInstance")
.property("status", &libOpenCOR::SedInstance::status)
.function("run", &libOpenCOR::SedInstance::run)
.function("startRun", &libOpenCOR::SedInstance::startRun)
.property("isRunning", &libOpenCOR::SedInstance::isRunning)
.function("waitForRun", &libOpenCOR::SedInstance::waitForRun)
Comment thread
agarny marked this conversation as resolved.
.function("pauseRun", &libOpenCOR::SedInstance::pauseRun)
.function("resumeRun", &libOpenCOR::SedInstance::resumeRun)
Expand All @@ -101,6 +106,14 @@ void sedApi()
.property("tasks", &libOpenCOR::SedInstance::tasks)
.function("task", &libOpenCOR::SedInstance::task);

EM_ASM({
if (Module["SedInstance"]) {
Module["SedInstance"]["Status"] = Module["SedInstance.Status"];

delete Module["SedInstance.Status"];
}
});

// SedInstanceTask API.

emscripten::class_<libOpenCOR::SedInstanceTask, emscripten::base<libOpenCOR::Logger>>("SedInstanceTask")
Expand Down
3 changes: 1 addition & 2 deletions src/bindings/python/file.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,7 @@ void fileApi(nb::module_ &m)
.value("CellmlFile", libOpenCOR::File::Type::CELLML_FILE)
.value("SedmlFile", libOpenCOR::File::Type::SEDML_FILE)
.value("CombineArchive", libOpenCOR::File::Type::COMBINE_ARCHIVE)
.value("IrretrievableFile", libOpenCOR::File::Type::IRRETRIEVABLE_FILE)
.export_values();
.value("IrretrievableFile", libOpenCOR::File::Type::IRRETRIEVABLE_FILE);

file.def(nb::new_(&libOpenCOR::File::create), "Create a File object.", nb::arg("file_name_or_url"), nb::arg("retrieve_contents") = true)
.def_prop_ro("type", &libOpenCOR::File::type, "Return the type.")
Expand Down
3 changes: 1 addition & 2 deletions src/bindings/python/logger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,7 @@ void loggerApi(nb::module_ &m)

nb::enum_<libOpenCOR::Issue::Type>(issue, "Type")
.value("Error", libOpenCOR::Issue::Type::ERROR)
.value("Warning", libOpenCOR::Issue::Type::WARNING)
.export_values();
.value("Warning", libOpenCOR::Issue::Type::WARNING);

issue.def_prop_ro("type", &libOpenCOR::Issue::type, "Return the type.")
.def_prop_ro("type_as_string", &libOpenCOR::Issue::typeAsString, "Return the type as a string.")
Expand Down
9 changes: 7 additions & 2 deletions src/bindings/python/sed.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,14 @@ void sedApi(nb::module_ &m)

nb::class_<libOpenCOR::SedInstance, libOpenCOR::Logger> sedInstance(m, "SedInstance");

sedInstance.def("run", &libOpenCOR::SedInstance::run, "Run all the tasks associated with this instance.", nb::call_guard<nb::gil_scoped_release>())
nb::enum_<libOpenCOR::SedInstance::Status>(sedInstance, "Status")
.value("Idle", libOpenCOR::SedInstance::Status::IDLE)
.value("Running", libOpenCOR::SedInstance::Status::RUNNING)
.value("Paused", libOpenCOR::SedInstance::Status::PAUSED);

sedInstance.def_prop_ro("status", &libOpenCOR::SedInstance::status, "Return the status of this instance.")
.def("run", &libOpenCOR::SedInstance::run, "Run all the tasks associated with this instance.", nb::call_guard<nb::gil_scoped_release>())
.def("start_run", &libOpenCOR::SedInstance::startRun, "Start running, in a background thread, all the tasks associated with this instance.")
.def_prop_ro("is_running", &libOpenCOR::SedInstance::isRunning, "Return whether this instance is currently running.")
.def("wait_for_run", &libOpenCOR::SedInstance::waitForRun, "Wait for any currently-running instance to complete.", nb::call_guard<nb::gil_scoped_release>())
Comment thread
agarny marked this conversation as resolved.
.def("pause_run", &libOpenCOR::SedInstance::pauseRun, "Pause a currently-running instance.")
.def("resume_run", &libOpenCOR::SedInstance::resumeRun, "Resume a currently-paused instance.")
Expand Down
18 changes: 6 additions & 12 deletions src/bindings/python/solver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,7 @@ void solverApi(nb::module_ &m)

nb::enum_<libOpenCOR::Solver::Type>(solver, "Type")
.value("Ode", libOpenCOR::Solver::Type::ODE)
.value("Nla", libOpenCOR::Solver::Type::NLA)
.export_values();
.value("Nla", libOpenCOR::Solver::Type::NLA);

solver.def_prop_ro("type", &libOpenCOR::Solver::type, "Return the type.")
.def_prop_ro("id", &libOpenCOR::Solver::id, "Return the (KiSAO) id.")
Expand Down Expand Up @@ -59,27 +58,23 @@ void solverApi(nb::module_ &m)

nb::enum_<libOpenCOR::SolverCvode::IntegrationMethod>(solverCvode, "IntegrationMethod")
.value("AdamsMoulton", libOpenCOR::SolverCvode::IntegrationMethod::ADAMS_MOULTON)
.value("Bdf", libOpenCOR::SolverCvode::IntegrationMethod::BDF)
.export_values();
.value("Bdf", libOpenCOR::SolverCvode::IntegrationMethod::BDF);

nb::enum_<libOpenCOR::SolverCvode::IterationType>(solverCvode, "IterationType")
.value("Functional", libOpenCOR::SolverCvode::IterationType::FUNCTIONAL)
.value("Newton", libOpenCOR::SolverCvode::IterationType::NEWTON)
.export_values();
.value("Newton", libOpenCOR::SolverCvode::IterationType::NEWTON);

nb::enum_<libOpenCOR::SolverCvode::LinearSolver>(solverCvode, "LinearSolver")
.value("Dense", libOpenCOR::SolverCvode::LinearSolver::DENSE)
.value("Banded", libOpenCOR::SolverCvode::LinearSolver::BANDED)
.value("Diagonal", libOpenCOR::SolverCvode::LinearSolver::DIAGONAL)
.value("Gmres", libOpenCOR::SolverCvode::LinearSolver::GMRES)
.value("Bicgstab", libOpenCOR::SolverCvode::LinearSolver::BICGSTAB)
.value("Tfqmr", libOpenCOR::SolverCvode::LinearSolver::TFQMR)
.export_values();
.value("Tfqmr", libOpenCOR::SolverCvode::LinearSolver::TFQMR);

nb::enum_<libOpenCOR::SolverCvode::Preconditioner>(solverCvode, "Preconditioner")
.value("No", libOpenCOR::SolverCvode::Preconditioner::NO)
.value("Banded", libOpenCOR::SolverCvode::Preconditioner::BANDED)
.export_values();
.value("Banded", libOpenCOR::SolverCvode::Preconditioner::BANDED);

solverCvode.def(nb::new_(&libOpenCOR::SolverCvode::create), "Create a SolverCvode object.")
.def_prop_rw("maximum_step", &libOpenCOR::SolverCvode::maximumStep, &libOpenCOR::SolverCvode::setMaximumStep, "The maximum step.")
Expand Down Expand Up @@ -121,8 +116,7 @@ void solverApi(nb::module_ &m)
.value("Banded", libOpenCOR::SolverKinsol::LinearSolver::BANDED)
.value("Gmres", libOpenCOR::SolverKinsol::LinearSolver::GMRES)
.value("Bicgstab", libOpenCOR::SolverKinsol::LinearSolver::BICGSTAB)
.value("Tfqmr", libOpenCOR::SolverKinsol::LinearSolver::TFQMR)
.export_values();
.value("Tfqmr", libOpenCOR::SolverKinsol::LinearSolver::TFQMR);

solverKinsol.def(nb::new_(&libOpenCOR::SolverKinsol::create), "Create a SolverKinsol object.")
.def_prop_rw("maximum_number_of_iterations", &libOpenCOR::SolverKinsol::maximumNumberOfIterations, &libOpenCOR::SolverKinsol::setMaximumNumberOfIterations, "The maximum number of iterations.")
Expand Down
28 changes: 18 additions & 10 deletions src/sed/sedinstance.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,19 @@ SedInstance::Impl::Impl(const SedDocumentPtr &pDocument)
}
}

SedInstance::Status SedInstance::Impl::status() const
{
if (!mRunning.load(std::memory_order_acquire)) {
return Status::IDLE;
}

if ((mRunControl.load(std::memory_order_relaxed) & INSTANCE_RUN_CONTROL_PAUSE) != 0U) {
return Status::PAUSED;
}

return Status::RUNNING;
}

double SedInstance::Impl::run()
{
// Reset ourselves.
Expand Down Expand Up @@ -171,11 +184,6 @@ bool SedInstance::Impl::startRun()
return true;
}

bool SedInstance::Impl::isRunning() const
{
return mRunning.load(std::memory_order_acquire);
}

double SedInstance::Impl::waitForRun()
{
const std::scoped_lock<std::mutex> runLock(mRunMutex);
Expand Down Expand Up @@ -270,6 +278,11 @@ const SedInstance::Impl *SedInstance::pimpl() const
return static_cast<const Impl *>(Logger::mPimpl.get());
}

SedInstance::Status SedInstance::status() const noexcept
{
return pimpl()->status();
}

double SedInstance::run()
{
return pimpl()->run();
Expand All @@ -280,11 +293,6 @@ bool SedInstance::startRun()
return pimpl()->startRun();
}

bool SedInstance::isRunning() const noexcept
{
return pimpl()->isRunning();
}

double SedInstance::waitForRun()
{
return pimpl()->waitForRun();
Expand Down
3 changes: 2 additions & 1 deletion src/sed/sedinstance_p.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,10 @@ class SedInstance::Impl: public Logger::Impl

explicit Impl(const SedDocumentPtr &pDocument);

Status status() const;

double run();
bool startRun();
bool isRunning() const;
double waitForRun();
void pauseRun();
void resumeRun();
Expand Down
2 changes: 1 addition & 1 deletion tests/api/sed/concurrenttests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ TEST(ConcurrentSedTest, parallelAsyncLifecycle)
}

for (const auto &instance : instances) {
EXPECT_FALSE(instance->isRunning());
EXPECT_EQ(instance->status(), libOpenCOR::SedInstance::Status::IDLE);
EXPECT_FALSE(instance->hasIssues());
}
}
Loading
Loading