aboutsummaryrefslogtreecommitdiff
path: root/helper
diff options
context:
space:
mode:
authorMatias Elo <matias.elo@nokia.com>2018-10-12 10:43:34 +0300
committerMaxim Uvarov <maxim.uvarov@linaro.org>2018-11-28 17:16:39 +0300
commit1065c7735a98611308f7430839a62e8a1fab40da (patch)
tree5c450dc44cae97eb76706ba0facda5de4d96524d /helper
parent5d002e728f60be318f235cc610b4f1dd631a34ba (diff)
helper: threads: add odph_options() getter function
Add function for reading parsed linux helper options. Signed-off-by: Matias Elo <matias.elo@nokia.com> Reviewed-by: Bill Fischofer <bill.fischofer@linaro.org> Reviewed-by: Petri Savolainen <petri.savolainen@linaro.org> Signed-off-by: Maxim Uvarov <maxim.uvarov@linaro.org>
Diffstat (limited to 'helper')
-rw-r--r--helper/include/odp/helper/threads.h17
-rw-r--r--helper/threads.c21
2 files changed, 31 insertions, 7 deletions
diff --git a/helper/include/odp/helper/threads.h b/helper/include/odp/helper/threads.h
index f4e8a785e..6cee2522d 100644
--- a/helper/include/odp/helper/threads.h
+++ b/helper/include/odp/helper/threads.h
@@ -88,6 +88,11 @@ typedef struct {
};
} odph_odpthread_t;
+/** Linux helper options */
+typedef struct {
+ odp_mem_model_t mem_model; /**< Process or thread */
+} odph_helper_options_t;
+
/**
* Creates and launches odpthreads (as linux threads or processes)
*
@@ -154,6 +159,18 @@ int odph_odpthread_getaffinity(void);
int odph_parse_options(int argc, char *argv[]);
/**
+ * Get linux helper options
+ *
+ * Return used ODP helper options. odph_parse_options() must be called before
+ * using this function.
+ *
+ * @param[out] options ODP helper options
+ *
+ * @return 0 on success, -1 on failure
+ */
+int odph_options(odph_helper_options_t *options);
+
+/**
* @}
*/
diff --git a/helper/threads.c b/helper/threads.c
index 1e03ce02e..01bc33eac 100644
--- a/helper/threads.c
+++ b/helper/threads.c
@@ -23,9 +23,7 @@
#define FAILED_CPU -1
-static struct {
- int proc; /* true when process mode is required, false otherwise */
-} helper_options;
+static odph_helper_options_t helper_options;
/*
* wrapper for odpthreads, either implemented as linux threads or processes.
@@ -181,7 +179,7 @@ int odph_odpthreads_create(odph_odpthread_t *thread_tbl,
cpu = odp_cpumask_first(mask);
for (i = 0; i < num; i++) {
- if (!helper_options.proc) {
+ if (helper_options.mem_model == ODP_MEM_MODEL_THREAD) {
if (odph_linux_thread_create(&thread_tbl[i],
cpu,
thr_params))
@@ -330,19 +328,19 @@ int odph_parse_options(int argc, char *argv[])
char *env;
int i, j;
- helper_options.proc = 0;
+ helper_options.mem_model = ODP_MEM_MODEL_THREAD;
/* Enable process mode using environment variable. Setting environment
* variable is easier for CI testing compared to command line
* argument. */
env = getenv("ODPH_PROC_MODE");
if (env && atoi(env))
- helper_options.proc = 1;
+ helper_options.mem_model = ODP_MEM_MODEL_PROCESS;
/* Find and remove option */
for (i = 0; i < argc;) {
if (strcmp(argv[i], "--odph_proc") == 0) {
- helper_options.proc = 1;
+ helper_options.mem_model = ODP_MEM_MODEL_PROCESS;
for (j = i; j < argc - 1; j++)
argv[j] = argv[j + 1];
@@ -356,3 +354,12 @@ int odph_parse_options(int argc, char *argv[])
return argc;
}
+
+int odph_options(odph_helper_options_t *options)
+{
+ memset(options, 0, sizeof(odph_helper_options_t));
+
+ options->mem_model = helper_options.mem_model;
+
+ return 0;
+}