Skip to content

Commit

Permalink
Checkpoint threading work.
Browse files Browse the repository at this point in the history
* Introduce qv_thread_scope_get().
* Bring back partial test-threads test.

Signed-off-by: Samuel K. Gutierrez <[email protected]>
  • Loading branch information
samuelkgutierrez committed Jul 9, 2024
1 parent a58e7dd commit b1a3d89
Show file tree
Hide file tree
Showing 9 changed files with 165 additions and 485 deletions.
6 changes: 6 additions & 0 deletions include/quo-vadis-thread.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,12 @@ qv_pthread_create(
qv_scope_t *scope
);

int
qv_thread_scope_get(
qv_scope_intrinsic_t iscope,
qv_scope_t **scope
);

int
qv_thread_scope_split_at(
qv_scope_t *scope,
Expand Down
16 changes: 16 additions & 0 deletions src/quo-vadis-thread.cc
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,29 @@
*/

#include "qvi-common.h" // IWYU pragma: keep
#include "qvi-group-thread.h"
#include "quo-vadis-thread.h"
#include "qvi-scope.h"
#include "qvi-utils.h"
#ifdef OPENMP_FOUND
#include <omp.h>
#endif

int
qv_thread_scope_get(
qv_scope_intrinsic_t iscope,
qv_scope_t **scope
) {
// Create the base process group.
qvi_group_thread_s *zgroup = nullptr;
const int rc = qvi_new(&zgroup);
if (rc != QV_SUCCESS) {
*scope = nullptr;
return rc;
}
return qvi_scope_get(zgroup, iscope, scope);
}

int
qv_thread_scope_split(
qv_scope_t *scope,
Expand Down
11 changes: 3 additions & 8 deletions src/qvi-group-thread.cc
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,7 @@ qvi_group_thread_s::make_intrinsic(
) {
// NOTE: the provided scope doesn't affect how
// we create the thread group, so we ignore it.
return qvi_thread_group_create(
th, &th_group
);
return qvi_thread_group_create(&th_group);
}

int
Expand All @@ -40,9 +38,7 @@ qvi_group_thread_s::self(
int rc = qvi_new(&ichild);
if (rc != QV_SUCCESS) goto out;
// Create a group containing a single thread
rc = qvi_thread_group_create_single(
th, &ichild->th_group
);
rc = qvi_thread_group_create_single(&ichild->th_group);
out:
if (rc != QV_SUCCESS) {
qvi_delete(&ichild);
Expand All @@ -62,8 +58,7 @@ qvi_group_thread_s::split(
if (rc != QV_SUCCESS) goto out;

rc = qvi_thread_group_create_from_split(
th, th_group, color,
key, &ichild->th_group
th_group, color, key, &ichild->th_group
);
out:
if (rc != QV_SUCCESS) {
Expand Down
14 changes: 2 additions & 12 deletions src/qvi-group-thread.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,19 +25,10 @@
#include "qvi-thread.h"

struct qvi_group_thread_s : public qvi_group_s {
/**
* Initialized qvi_thread_t instance
* embedded in thread group instances.
*/
qvi_thread_t *th = nullptr;
/** Underlying group instance. */
qvi_thread_group_t *th_group = nullptr;
/** Constructor. */
qvi_group_thread_s(void)
{
int rc = qvi_thread_new(&th);
if (rc != QV_SUCCESS) throw qvi_runtime_error();
}
qvi_group_thread_s(void) = default;
/** Destructor. */
virtual ~qvi_group_thread_s(void)
{
Expand All @@ -59,8 +50,7 @@ struct qvi_group_thread_s : public qvi_group_s {
virtual int
barrier(void)
{
// TODO(skg) FIXME
return QV_SUCCESS;
return qvi_thread_group_barrier(th_group);
}

virtual int
Expand Down
Loading

0 comments on commit b1a3d89

Please sign in to comment.