@@ -22,6 +22,7 @@
extern "C" {
#endif
+#include <odp.h>
#include <pthread.h>
#include <sys/types.h>
@@ -50,6 +51,16 @@ typedef struct {
int status; /**< Process state change status */
} odph_linux_process_t;
+/**
+ * Creates default pthread/process cpumask
+ *
+ * Creates cpumask based on starting count, actual value returned
+ *
+ * @param mask CPU mask to initialize
+ * @param num Number of threads to create, zero for all available
+ * @return Actual values of CPUs used to create mask
+ */
+int odph_linux_cpumask_default(odp_cpumask_t *mask, int num);
/**
* Creates and launches pthreads
@@ -25,6 +25,41 @@
#include <odp_system_info.h>
#include <odp_debug_internal.h>
+int odph_linux_cpumask_default(odp_cpumask_t *mask, int num_in)
+{
+ int i;
+ int first_cpu = 1;
+ int num = num_in;
+ int cpu_count;
+
+ cpu_count = odp_sys_cpu_count();
+
+ /*
+ * If no user supplied number or it's too large, then attempt
+ * to use all CPUs
+ */
+ if (0 == num)
+ num = cpu_count;
+ if (cpu_count < num)
+ num = cpu_count;
+
+ /*
+ * Always force "first_cpu" to a valid CPU
+ */
+ if (first_cpu >= cpu_count)
+ first_cpu = cpu_count - 1;
+
+ /* Build the mask */
+ odp_cpumask_zero(mask);
+ for (i = 0; i < num; i++) {
+ int cpu;
+
+ cpu = (first_cpu + i) % cpu_count;
+ odp_cpumask_set(mask, cpu);
+ }
+
+ return num;
+}
static void *odp_run_start_routine(void *arg)
{