Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[PATCH v4] api: thread: add functions for control/worker thread counts #1950

Merged
merged 6 commits into from
Dec 19, 2023
8 changes: 8 additions & 0 deletions include/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ odpapiinclude_HEADERS = \
odp/api/sync.h \
odp/api/system_info.h \
odp/api/thread.h \
odp/api/thread_types.h \
odp/api/threshold.h \
odp/api/thrmask.h \
odp/api/ticketlock.h \
Expand Down Expand Up @@ -193,6 +194,7 @@ odpapiabidefaultinclude_HEADERS = \
odp/api/abi-default/std_types.h \
odp/api/abi-default/sync.h \
odp/api/abi-default/thread.h \
odp/api/abi-default/thread_types.h \
odp/api/abi-default/thrmask.h \
odp/api/abi-default/ticketlock.h \
odp/api/abi-default/time.h \
Expand Down Expand Up @@ -255,6 +257,7 @@ odpapiabiarchinclude_HEADERS = \
odp/arch/arm32-linux/odp/api/abi/std_types.h \
odp/arch/arm32-linux/odp/api/abi/sync.h \
odp/arch/arm32-linux/odp/api/abi/thread.h \
odp/arch/arm32-linux/odp/api/abi/thread_types.h \
odp/arch/arm32-linux/odp/api/abi/thrmask.h \
odp/arch/arm32-linux/odp/api/abi/ticketlock.h \
odp/arch/arm32-linux/odp/api/abi/time.h \
Expand Down Expand Up @@ -313,6 +316,7 @@ odpapiabiarchinclude_HEADERS = \
odp/arch/arm64-linux/odp/api/abi/std_types.h \
odp/arch/arm64-linux/odp/api/abi/sync.h \
odp/arch/arm64-linux/odp/api/abi/thread.h \
odp/arch/arm64-linux/odp/api/abi/thread_types.h \
odp/arch/arm64-linux/odp/api/abi/thrmask.h \
odp/arch/arm64-linux/odp/api/abi/ticketlock.h \
odp/arch/arm64-linux/odp/api/abi/time.h \
Expand Down Expand Up @@ -371,6 +375,7 @@ odpapiabiarchinclude_HEADERS = \
odp/arch/default-linux/odp/api/abi/std_types.h \
odp/arch/default-linux/odp/api/abi/sync.h \
odp/arch/default-linux/odp/api/abi/thread.h \
odp/arch/default-linux/odp/api/abi/thread_types.h \
odp/arch/default-linux/odp/api/abi/thrmask.h \
odp/arch/default-linux/odp/api/abi/ticketlock.h \
odp/arch/default-linux/odp/api/abi/time.h \
Expand Down Expand Up @@ -429,6 +434,7 @@ odpapiabiarchinclude_HEADERS = \
odp/arch/power64-linux/odp/api/abi/std_types.h \
odp/arch/power64-linux/odp/api/abi/sync.h \
odp/arch/power64-linux/odp/api/abi/thread.h \
odp/arch/power64-linux/odp/api/abi/thread_types.h \
odp/arch/power64-linux/odp/api/abi/thrmask.h \
odp/arch/power64-linux/odp/api/abi/ticketlock.h \
odp/arch/power64-linux/odp/api/abi/time.h \
Expand Down Expand Up @@ -487,6 +493,7 @@ odpapiabiarchinclude_HEADERS = \
odp/arch/x86_32-linux/odp/api/abi/std_types.h \
odp/arch/x86_32-linux/odp/api/abi/sync.h \
odp/arch/x86_32-linux/odp/api/abi/thread.h \
odp/arch/x86_32-linux/odp/api/abi/thread_types.h \
odp/arch/x86_32-linux/odp/api/abi/thrmask.h \
odp/arch/x86_32-linux/odp/api/abi/ticketlock.h \
odp/arch/x86_32-linux/odp/api/abi/time.h \
Expand Down Expand Up @@ -545,6 +552,7 @@ odpapiabiarchinclude_HEADERS = \
odp/arch/x86_64-linux/odp/api/abi/std_types.h \
odp/arch/x86_64-linux/odp/api/abi/sync.h \
odp/arch/x86_64-linux/odp/api/abi/thread.h \
odp/arch/x86_64-linux/odp/api/abi/thread_types.h \
odp/arch/x86_64-linux/odp/api/abi/thrmask.h \
odp/arch/x86_64-linux/odp/api/abi/ticketlock.h \
odp/arch/x86_64-linux/odp/api/abi/time.h \
Expand Down
16 changes: 1 addition & 15 deletions include/odp/api/abi-default/thread.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,14 @@
* Copyright (c) 2015-2018 Linaro Limited
*/

/**
* @file
*
* ODP thread
*/

#ifndef ODP_ABI_THREAD_H_
#define ODP_ABI_THREAD_H_

#ifdef __cplusplus
extern "C" {
#endif

/** @addtogroup odp_thread
* @{
*/

#define ODP_THREAD_COUNT_MAX 256

/**
* @}
*/
/* Empty header required due to the inline functions */

#ifdef __cplusplus
}
Expand Down
26 changes: 26 additions & 0 deletions include/odp/api/abi-default/thread_types.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/* SPDX-License-Identifier: BSD-3-Clause
* Copyright (c) 2023 Nokia
*/

#ifndef ODP_ABI_THREAD_TYPES_H_
#define ODP_ABI_THREAD_TYPES_H_

#ifdef __cplusplus
extern "C" {
#endif

/** @ingroup odp_thread
* @{
*/

#define ODP_THREAD_COUNT_MAX 256

/**
* @}
*/

#ifdef __cplusplus
}
#endif

#endif
2 changes: 1 addition & 1 deletion include/odp/api/spec/init.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ extern "C" {

#include <odp/api/std_types.h>
#include <odp/api/hints.h>
#include <odp/api/spec/thread_types.h>
#include <odp/api/thread_types.h>
#include <odp/api/cpumask.h>

/** @defgroup odp_initialization ODP INITIALIZATION
Expand Down
66 changes: 53 additions & 13 deletions include/odp/api/spec/thread.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* SPDX-License-Identifier: BSD-3-Clause
* Copyright (c) 2013-2018 Linaro Limited
* Copyright (c) 2022 Nokia
* Copyright (c) 2022-2023 Nokia
*/

/**
Expand All @@ -17,18 +17,13 @@
extern "C" {
#endif

#include <odp/api/thread_types.h>

/** @defgroup odp_thread ODP THREAD
* Thread types, masks and IDs.
* @{
*/

/**
* @def ODP_THREAD_COUNT_MAX
* Maximum number of threads supported in build time. Use
* odp_thread_count_max() for maximum number of threads supported in run time,
* which depend on system configuration and may be lower than this number.
*/

/**
* Get thread identifier
*
Expand All @@ -48,24 +43,69 @@ int odp_thread_id(void);
* Thread count
*
* Returns the current ODP thread count. This is the number of active threads
* running the ODP instance. Each odp_init_local() call increments and each
* odp_term_local() call decrements the count. The count is always between 1 and
* odp_thread_count_max().
* of any type running in the ODP instance. Each odp_init_local() call
* increments and each odp_term_local() call decrements the count. The count is
* always between 1 and odp_thread_count_max().
*
* @return Current thread count
*/
int odp_thread_count(void);

/**
* Control thread count
*
* Otherwise like odp_thread_count(), but returns the number of active threads
* of type #ODP_THREAD_CONTROL. The count is always between 0 and
* odp_thread_control_count_max().
*
* @return Current control thread count
*/
int odp_thread_control_count(void);

/**
* Worker thread count
*
* Otherwise like odp_thread_count(), but returns the number of active threads
* of type #ODP_THREAD_WORKER. The count is always between 0 and
* odp_thread_worker_count_max().
*
* @return Current worker thread count
*/
int odp_thread_worker_count(void);

/**
* Maximum thread count
*
* Returns the maximum thread count, which is a constant value and set in
* ODP initialization phase. This may be lower than ODP_THREAD_COUNT_MAX.
* Returns the maximum number of threads of any type. This is a constant value
* and set in ODP initialization phase. The value may be lower than
* #ODP_THREAD_COUNT_MAX.
*
* @return Maximum thread count
*/
int odp_thread_count_max(void);

/**
* Maximum control thread count
*
* Otherwise like odp_thread_count_max(), but returns the maximum number of
* control threads (#ODP_THREAD_CONTROL). The returned value is always <=
* odp_thread_count_max().
*
* @return Maximum control thread count
*/
int odp_thread_control_count_max(void);

/**
* Maximum worker thread count
*
* Otherwise like odp_thread_count_max(), but returns the maximum number of
* worker threads (#ODP_THREAD_WORKER). The returned value is always <=
* odp_thread_count_max().
*
* @return Maximum worker thread count
*/
int odp_thread_worker_count_max(void);

/**
* Thread type
*
Expand Down
7 changes: 7 additions & 0 deletions include/odp/api/spec/thread_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,13 @@ extern "C" {
* @{
*/

/**
* @def ODP_THREAD_COUNT_MAX
* Maximum number of threads supported in build time. Use odp_thread_count_max()
* for maximum number of threads supported in run time, which depends on system
* configuration and may be lower than this number.
*/

/**
* Thread type
*/
Expand Down
2 changes: 0 additions & 2 deletions include/odp/api/thread.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@
extern "C" {
#endif

#include <odp/api/spec/thread_types.h>

#include <odp/api/abi/thread.h>

#include <odp/api/spec/thread.h>
Expand Down
26 changes: 26 additions & 0 deletions include/odp/api/thread_types.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/* SPDX-License-Identifier: BSD-3-Clause
* Copyright (c) 2023 Nokia
*/

/**
* @file
*
* ODP thread
*/

#ifndef ODP_API_THREAD_TYPES_H_
#define ODP_API_THREAD_TYPES_H_

#ifdef __cplusplus
extern "C" {
#endif

#include <odp/api/abi/thread_types.h>

#include <odp/api/spec/thread_types.h>

#ifdef __cplusplus
}
#endif

#endif
5 changes: 5 additions & 0 deletions include/odp/arch/arm32-linux/odp/api/abi/thread_types.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/* SPDX-License-Identifier: BSD-3-Clause
* Copyright (c) 2023 Nokia
*/

#include <odp/api/abi-default/thread_types.h>
5 changes: 5 additions & 0 deletions include/odp/arch/arm64-linux/odp/api/abi/thread_types.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/* SPDX-License-Identifier: BSD-3-Clause
* Copyright (c) 2023 Nokia
*/

#include <odp/api/abi-default/thread_types.h>
5 changes: 5 additions & 0 deletions include/odp/arch/default-linux/odp/api/abi/thread_types.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/* SPDX-License-Identifier: BSD-3-Clause
* Copyright (c) 2023 Nokia
*/

#include <odp/api/abi-default/thread_types.h>
5 changes: 5 additions & 0 deletions include/odp/arch/power64-linux/odp/api/abi/thread_types.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/* SPDX-License-Identifier: BSD-3-Clause
* Copyright (c) 2023 Nokia
*/

#include <odp/api/abi-default/thread_types.h>
5 changes: 5 additions & 0 deletions include/odp/arch/x86_32-linux/odp/api/abi/thread_types.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/* SPDX-License-Identifier: BSD-3-Clause
* Copyright (c) 2023 Nokia
*/

#include <odp/api/abi-default/thread_types.h>
5 changes: 5 additions & 0 deletions include/odp/arch/x86_64-linux/odp/api/abi/thread_types.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/* SPDX-License-Identifier: BSD-3-Clause
* Copyright (c) 2023 Nokia
*/

#include <odp/api/abi-default/thread_types.h>
1 change: 1 addition & 0 deletions platform/linux-generic/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ odpapiabiarchinclude_HEADERS += \
include-abi/odp/api/abi/std_types.h \
include-abi/odp/api/abi/sync.h \
include-abi/odp/api/abi/thread.h \
include-abi/odp/api/abi/thread_types.h \
include-abi/odp/api/abi/thrmask.h \
include-abi/odp/api/abi/ticketlock.h \
include-abi/odp/api/abi/time.h \
Expand Down
3 changes: 1 addition & 2 deletions platform/linux-generic/include-abi/odp/api/abi/thread.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,5 @@
* SPDX-License-Identifier: BSD-3-Clause
*/

#include <odp/api/abi-default/thread.h>

/* Inlined API functions */
#include <odp/api/plat/thread_inlines.h>
5 changes: 5 additions & 0 deletions platform/linux-generic/include-abi/odp/api/abi/thread_types.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/* SPDX-License-Identifier: BSD-3-Clause
* Copyright (c) 2023 Nokia
*/

#include <odp/api/abi-default/thread_types.h>
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#define ODP_PLAT_THREAD_INLINE_TYPES_H_

#include <odp/api/init.h>
#include <odp/api/spec/thread_types.h>
#include <odp/api/thread_types.h>

#ifdef __cplusplus
extern "C" {
Expand Down
8 changes: 4 additions & 4 deletions platform/linux-generic/include/odp/api/plat/thread_inlines.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@
#ifndef ODP_PLAT_THREAD_INLINES_H_
#define ODP_PLAT_THREAD_INLINES_H_

#include <odp/api/init.h>

#include <odp/api/plat/thread_inline_types.h>

#ifdef __cplusplus
extern "C" {
#endif

#include <odp/api/thread_types.h>

#include <odp/api/plat/thread_inline_types.h>

/** @cond _ODP_HIDE_FROM_DOXYGEN_ */

#ifndef _ODP_NO_INLINE
Expand Down
Loading
Loading