Skip to content

Commit

Permalink
Differentiate between Pthread and OpenMP Infrastructure. (#210)
Browse files Browse the repository at this point in the history
Signed-off-by: Samuel K. Gutierrez <[email protected]>
  • Loading branch information
samuelkgutierrez authored Jul 11, 2024
1 parent 244c3ae commit c70d13c
Show file tree
Hide file tree
Showing 17 changed files with 344 additions and 333 deletions.
25 changes: 17 additions & 8 deletions include/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# Copyright (c) 2020-2022 Triad National Security, LLC
# Copyright (c) 2020-2024 Triad National Security, LLC
# All rights reserved.
#
# Copyright (c) 2020-2021 Lawrence Livermore National Security, LLC
Expand All @@ -14,18 +14,27 @@ install(
FILES
quo-vadis.h
quo-vadis-process.h
quo-vadis-thread.h
quo-vadis-pthread.h
DESTINATION
include
)

if(OpenMP_C_FOUND)
install(
FILES
quo-vadis-omp.h
DESTINATION
include
)
endif()

if(MPI_FOUND)
install(
FILES
quo-vadis-mpi.h
DESTINATION
include
)
install(
FILES
quo-vadis-mpi.h
DESTINATION
include
)
endif()

# vim: ts=4 sts=4 sw=4 expandtab
43 changes: 43 additions & 0 deletions include/quo-vadis-omp.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/* -*- Mode: C; c-basic-offset:4; indent-tabs-mode:nil -*- */
/*
* Copyright (c) 2022-2024 Triad National Security, LLC
* All rights reserved.
*
* Copyright (c) 2022-2024 Inria
* All rights reserved.
*
* Copyright (c) 2022-2024 Bordeaux INP
* All rights reserved.
*
* This file is part of the quo-vadis project. See the LICENSE file at the
* top-level directory of this distribution.
*/

/**
* @file quo-vadis-omp.h
*/

#ifndef QUO_VADIS_OMP_H
#define QUO_VADIS_OMP_H

#include "quo-vadis.h"

#ifdef __cplusplus
extern "C" {
#endif

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

#ifdef __cplusplus
}
#endif

#endif

/*
* vim: ft=cpp ts=4 sts=4 sw=4 expandtab
*/
12 changes: 3 additions & 9 deletions include/quo-vadis-thread.h → include/quo-vadis-pthread.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@
*/

/**
* @file quo-vadis-thread.h
* @file quo-vadis-pthread.h
*/

#ifndef QUO_VADIS_THREAD_H
#define QUO_VADIS_THREAD_H
#ifndef QUO_VADIS_PTHREAD_H
#define QUO_VADIS_PTHREAD_H

#include "quo-vadis.h"
#include <pthread.h>
Expand Down Expand Up @@ -47,12 +47,6 @@ 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
64 changes: 49 additions & 15 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ add_library(
quo-vadis-core
OBJECT
../include/quo-vadis.h
../include/quo-vadis-pthread.h
qvi-common.h
qvi-macros.h
qvi-log.h
Expand Down Expand Up @@ -43,6 +44,7 @@ add_library(
qvi-map.cc
qvi-scope.cc
quo-vadis.cc
quo-vadis-pthread.cc
)

set_target_properties(
Expand Down Expand Up @@ -89,33 +91,65 @@ set(
quo-vadis-process.cc
)

# TODO(skg) We need to fix this. OpenMP builds versus Pthread.
if(OpenMP_C_FOUND)
set(
QUO_VADIS_SOURCE
${QUO_VADIS_SOURCE}
qvi-thread.h
qvi-group-thread.h
../include/quo-vadis-thread.h
qvi-thread.cc
qvi-group-thread.cc
quo-vadis-thread.cc
)
endif()

add_library(
quo-vadis
SHARED
${QUO_VADIS_SOURCE}
)

if(OpenMP_C_FOUND)
add_library(
quo-vadis-omp
SHARED
qvi-omp.h
qvi-group-omp.h
../include/quo-vadis-omp.h
qvi-omp.cc
qvi-group-omp.cc
quo-vadis-omp.cc
)

set_target_properties(
quo-vadis
quo-vadis-omp
PROPERTIES
COMPILE_FLAGS ${OpenMP_C_FLAGS}
LINK_FLAGS ${OpenMP_C_FLAGS}
)

target_include_directories(
quo-vadis-omp
PUBLIC
$<TARGET_PROPERTY:quo-vadis-core,INCLUDE_DIRECTORIES>
${MPI_C_INCLUDE_DIRS}
)

target_link_libraries(
quo-vadis-omp
quo-vadis-core
${MPI_C_LIBRARIES}
)

install(
TARGETS
quo-vadis-omp
DESTINATION
lib
)

# pkg-config ###############################################################
set(QV_PKG_LIBRARIES "-lquo-vadis-omp")
configure_file(
"${CMAKE_SOURCE_DIR}/pkgconfig/pkg-config.pc.in"
"${CMAKE_BINARY_DIR}/${PROJECT_NAME}-omp.pc"
@ONLY
)

install(
FILES
"${CMAKE_BINARY_DIR}/${PROJECT_NAME}-omp.pc"
DESTINATION
lib/pkgconfig
)
endif()

target_include_directories(
Expand Down
43 changes: 43 additions & 0 deletions src/quo-vadis-omp.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/* -*- Mode: C++; c-basic-offset:4; indent-tabs-mode:nil -*- */
/*
* Copyright (c) 2022-2024 Triad National Security, LLC
* All rights reserved.
*
* Copyright (c) 2022-2024 Inria
* All rights reserved.
*
* Copyright (c) 2022-2024 Bordeaux INP
* All rights reserved.
*
* This file is part of the quo-vadis project. See the LICENSE file at the
* top-level directory of this distribution.
*/

/**
* @file quo-vadis-thread.cc
*/

#include "qvi-common.h" // IWYU pragma: keep
#include "quo-vadis-omp.h"
#include "qvi-group-omp.h"
#include "qvi-scope.h"
#include "qvi-utils.h"

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

/*
* vim: ft=cpp ts=4 sts=4 sw=4 expandtab
*/
23 changes: 2 additions & 21 deletions src/quo-vadis-thread.cc → src/quo-vadis-pthread.cc
Original file line number Diff line number Diff line change
Expand Up @@ -14,32 +14,13 @@
*/

/**
* @file quo-vadis-thread.cc
* @file quo-vadis-pthread.cc
*/

#include "qvi-common.h" // IWYU pragma: keep
#include "qvi-group-thread.h"
#include "quo-vadis-thread.h"
#include "quo-vadis-pthread.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(
Expand Down
20 changes: 10 additions & 10 deletions src/qvi-group-thread.cc → src/qvi-group-omp.cc
Original file line number Diff line number Diff line change
Expand Up @@ -14,30 +14,30 @@
*/

/**
* @file qvi-group-thread.cc
* @file qvi-group-omp.cc
*/

#include "qvi-group-thread.h"
#include "qvi-group-omp.h"
#include "qvi-utils.h"

int
qvi_group_thread_s::make_intrinsic(
qvi_group_omp_s::make_intrinsic(
qv_scope_intrinsic_t
) {
// NOTE: the provided scope doesn't affect how
// we create the thread group, so we ignore it.
return qvi_thread_group_create(&th_group);
return qvi_omp_group_create(&th_group);
}

int
qvi_group_thread_s::self(
qvi_group_omp_s::self(
qvi_group_t **child
) {
qvi_group_thread_t *ichild = nullptr;
qvi_group_omp_t *ichild = nullptr;
int rc = qvi_new(&ichild);
if (rc != QV_SUCCESS) goto out;
// Create a group containing a single thread
rc = qvi_thread_group_create_single(&ichild->th_group);
rc = qvi_omp_group_create_single(&ichild->th_group);
out:
if (rc != QV_SUCCESS) {
qvi_delete(&ichild);
Expand All @@ -47,16 +47,16 @@ qvi_group_thread_s::self(
}

int
qvi_group_thread_s::split(
qvi_group_omp_s::split(
int color,
int key,
qvi_group_t **child
) {
qvi_group_thread_t *ichild = nullptr;
qvi_group_omp_t *ichild = nullptr;
int rc = qvi_new(&ichild);
if (rc != QV_SUCCESS) goto out;

rc = qvi_thread_group_create_from_split(
rc = qvi_omp_group_create_from_split(
th_group, color, key, &ichild->th_group
);
out:
Expand Down
Loading

0 comments on commit c70d13c

Please sign in to comment.