From patchwork Mon Dec 15 21:00:05 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ola Liljedahl X-Patchwork-Id: 42291 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wi0-f198.google.com (mail-wi0-f198.google.com [209.85.212.198]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 22FF72456A for ; Mon, 15 Dec 2014 21:00:41 +0000 (UTC) Received: by mail-wi0-f198.google.com with SMTP id r20sf4076448wiv.5 for ; Mon, 15 Dec 2014 13:00:40 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:date:message-id:in-reply-to :references:subject:precedence:list-id:list-unsubscribe:list-archive :list-post:list-help:list-subscribe:mime-version:content-type :content-transfer-encoding:errors-to:sender:x-original-sender :x-original-authentication-results:mailing-list; bh=Ml/8JfjSbmnIhzh4H1SxTPnz1vbbh7iVVWqKBF5WgHk=; b=PJu61xBsaPbQmVy3/CuXMX9P9a+QbLr648ubIpxfQRKJ5plo4J2rb/8oShOX6JvW1d jUNwASVFu9o43NfFDsmWXfpHIIKNpIaziaKmfnR0F+QR4V0FAktiTOzdJfDrylBKd2dg w6NMEbf+oJP9l8Sf3Am5lJThWB4IlhiSHwx5XBajS+Ltm/nLKHLQAX8Q8iK2t5O2Yzgk kkr3Yp2kxiwC1Dwu9vGKzugMGM0R/Jvyh/QcHc0YGvm0k4/3dbLtWcrlfMrB+9QkqnZd VAJFWSBo+3UVW/8JKPezp1CmWLu7fD6l6DPjCX8SJhepf5QhAVYL+0k2DARzZKP8ioSv 1jdQ== X-Gm-Message-State: ALoCoQlH4vaqtDD53jCQ6jiiM3MNBYMXyfj5fIPWJeYQnwjPeZPFyAejhPxPI3NY3w3EW0+xEtKh X-Received: by 10.180.98.39 with SMTP id ef7mr3131401wib.6.1418677240453; Mon, 15 Dec 2014 13:00:40 -0800 (PST) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.3.202 with SMTP id e10ls734598lae.86.gmail; Mon, 15 Dec 2014 13:00:40 -0800 (PST) X-Received: by 10.152.234.169 with SMTP id uf9mr31977333lac.86.1418677240091; Mon, 15 Dec 2014 13:00:40 -0800 (PST) Received: from mail-lb0-f171.google.com (mail-lb0-f171.google.com. [209.85.217.171]) by mx.google.com with ESMTPS id ti8si11567148lbb.95.2014.12.15.13.00.40 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 15 Dec 2014 13:00:40 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.171 as permitted sender) client-ip=209.85.217.171; Received: by mail-lb0-f171.google.com with SMTP id w7so5617379lbi.16 for ; Mon, 15 Dec 2014 13:00:40 -0800 (PST) X-Received: by 10.152.5.226 with SMTP id v2mr21280381lav.34.1418677239977; Mon, 15 Dec 2014 13:00:39 -0800 (PST) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.142.69 with SMTP id ru5csp839121lbb; Mon, 15 Dec 2014 13:00:37 -0800 (PST) X-Received: by 10.224.79.212 with SMTP id q20mr60638527qak.4.1418677236682; Mon, 15 Dec 2014 13:00:36 -0800 (PST) Received: from ip-10-35-177-41.ec2.internal (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTPS id x8si12003256qab.52.2014.12.15.13.00.35 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Mon, 15 Dec 2014 13:00:36 -0800 (PST) Received-SPF: none (google.com: lng-odp-bounces@lists.linaro.org does not designate permitted sender hosts) client-ip=54.225.227.206; Received: from localhost ([127.0.0.1] helo=ip-10-35-177-41.ec2.internal) by ip-10-35-177-41.ec2.internal with esmtp (Exim 4.76) (envelope-from ) id 1Y0ckq-0000Jw-UG; Mon, 15 Dec 2014 21:00:32 +0000 Received: from mail-la0-f49.google.com ([209.85.215.49]) by ip-10-35-177-41.ec2.internal with esmtp (Exim 4.76) (envelope-from ) id 1Y0cke-0000JE-74 for lng-odp@lists.linaro.org; Mon, 15 Dec 2014 21:00:20 +0000 Received: by mail-la0-f49.google.com with SMTP id hs14so10220445lab.36 for ; Mon, 15 Dec 2014 13:00:14 -0800 (PST) X-Received: by 10.112.17.102 with SMTP id n6mr19435106lbd.39.1418677214638; Mon, 15 Dec 2014 13:00:14 -0800 (PST) Received: from macmini.lan (84-217-193-77.tn.glocalnet.net. [84.217.193.77]) by mx.google.com with ESMTPSA id zc5sm2915610lbb.49.2014.12.15.13.00.13 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 15 Dec 2014 13:00:13 -0800 (PST) From: Ola Liljedahl To: lng-odp@lists.linaro.org Date: Mon, 15 Dec 2014 22:00:05 +0100 Message-Id: <1418677206-23017-2-git-send-email-ola.liljedahl@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1418677206-23017-1-git-send-email-ola.liljedahl@linaro.org> References: <1418677206-23017-1-git-send-email-ola.liljedahl@linaro.org> X-Topics: patch Subject: [lng-odp] [PATCH 1/2] api: odp_system_info.h: core->cpu, rename odp_core_count() to odp_cpu_count(), change "core" to "cpu"/"CPU" in messages and comments X-BeenThere: lng-odp@lists.linaro.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: , List-Help: , List-Subscribe: , MIME-Version: 1.0 Errors-To: lng-odp-bounces@lists.linaro.org Sender: lng-odp-bounces@lists.linaro.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: ola.liljedahl@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.171 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 Signed-off-by: Ola Liljedahl Signed-off-by: Ola Liljedahl --- (This document/code contribution attached is provided under the terms of agreement LES-LTM-21309) example/generator/odp_generator.c | 38 ++++++++++---------- example/ipsec/odp_ipsec.c | 32 ++++++++--------- example/l2fwd/odp_l2fwd.c | 42 +++++++++++----------- example/odp_example/odp_example.c | 38 ++++++++++---------- example/packet/odp_pktio.c | 40 ++++++++++----------- example/timer/odp_timer_test.c | 38 ++++++++++---------- helper/include/odph_linux.h | 24 ++++++------- .../linux-generic/include/api/odp_system_info.h | 8 +++-- platform/linux-generic/include/api/odp_thread.h | 6 ++-- platform/linux-generic/odp_linux.c | 34 +++++++++--------- platform/linux-generic/odp_system_info.c | 22 ++++++------ platform/linux-generic/odp_thread.c | 2 +- test/api_test/odp_atomic_test.c | 6 ++-- test/api_test/odp_common.c | 8 ++--- test/api_test/odp_ring_test.c | 2 +- test/api_test/odp_shm_test.c | 2 +- 16 files changed, 172 insertions(+), 170 deletions(-) diff --git a/example/generator/odp_generator.c b/example/generator/odp_generator.c index 8c227bc..ea73e73 100644 --- a/example/generator/odp_generator.c +++ b/example/generator/odp_generator.c @@ -45,7 +45,7 @@ * Parsed command line application arguments */ typedef struct { - int core_count; /**< system core count */ + int cpu_count; /**< system CPU count */ int if_count; /**< Number of interfaces to be used */ char **if_names; /**< Array of pointers to interface names */ odp_buffer_pool_t pool; /**< Buffer pool for packet IO */ @@ -524,8 +524,8 @@ int main(int argc, char *argv[]) int num_workers; void *pool_base; int i; - int first_core; - int core_count; + int first_cpu; + int cpu_count; odp_shm_t shm; /* Init ODP before calling anything else */ @@ -562,11 +562,11 @@ int main(int argc, char *argv[]) /* Print both system and application information */ print_info(NO_PATH(argv[0]), &args->appl); - core_count = odp_sys_core_count(); - num_workers = core_count; + cpu_count = odp_sys_cpu_count(); + num_workers = cpu_count; - if (args->appl.core_count) - num_workers = args->appl.core_count; + if (args->appl.cpu_count) + num_workers = args->appl.cpu_count; if (num_workers > MAX_WORKERS) num_workers = MAX_WORKERS; @@ -578,15 +578,15 @@ int main(int argc, char *argv[]) printf("Num worker threads: %i\n", num_workers); /* - * By default core #0 runs Linux kernel background tasks. - * Start mapping thread from core #1 + * By default CPU #0 runs Linux kernel background tasks. + * Start mapping thread from CPU #1 */ - first_core = 1; + first_cpu = 1; - if (core_count == 1) - first_core = 0; + if (cpu_count == 1) + first_cpu = 0; - printf("First core: %i\n\n", first_core); + printf("First CPU: %i\n\n", first_cpu); /* Create packet pool */ shm = odp_shm_reserve("shm_packet_pool", @@ -630,10 +630,10 @@ int main(int argc, char *argv[]) } else { for (i = 0; i < num_workers; ++i) { void *(*thr_run_func) (void *); - int core; + int cpu; int if_idx; - core = (first_core + i) % core_count; + cpu = (first_cpu + i) % cpu_count; if_idx = i % args->appl.if_count; @@ -655,7 +655,7 @@ int main(int argc, char *argv[]) * Calls odp_thread_create(cpu) for each thread */ odph_linux_pthread_create(&thread_tbl[i], 1, - core, thr_run_func, + cpu, thr_run_func, &args->thread[i]); } } @@ -711,7 +711,7 @@ static void parse_args(int argc, char *argv[], appl_args_t *appl_args) switch (opt) { case 'w': - appl_args->core_count = atoi(optarg); + appl_args->cpu_count = atoi(optarg); break; /* parse packet-io interface names */ case 'I': @@ -849,10 +849,10 @@ static void print_info(char *progname, appl_args_t *appl_args) "CPU model: %s\n" "CPU freq (hz): %"PRIu64"\n" "Cache line size: %i\n" - "Core count: %i\n" + "CPU count: %i\n" "\n", odp_version_api_str(), odp_sys_cpu_model_str(), odp_sys_cpu_hz(), - odp_sys_cache_line_size(), odp_sys_core_count()); + odp_sys_cache_line_size(), odp_sys_cpu_count()); printf("Running ODP appl: \"%s\"\n" "-----------------\n" diff --git a/example/ipsec/odp_ipsec.c b/example/ipsec/odp_ipsec.c index 538f8dc..d403b29 100644 --- a/example/ipsec/odp_ipsec.c +++ b/example/ipsec/odp_ipsec.c @@ -50,7 +50,7 @@ * Parsed command line application arguments */ typedef struct { - int core_count; + int cpu_count; int if_count; /**< Number of interfaces to be used */ char **if_names; /**< Array of pointers to interface names */ crypto_api_mode_e mode; /**< Crypto API preferred mode */ @@ -1178,8 +1178,8 @@ main(int argc, char *argv[]) int num_workers; void *pool_base; int i; - int first_core; - int core_count; + int first_cpu; + int cpu_count; int stream_count; odp_shm_t shm; @@ -1219,11 +1219,11 @@ main(int argc, char *argv[]) /* Print both system and application information */ print_info(NO_PATH(argv[0]), &args->appl); - core_count = odp_sys_core_count(); - num_workers = core_count; + cpu_count = odp_sys_cpu_count(); + num_workers = cpu_count; - if (args->appl.core_count) - num_workers = args->appl.core_count; + if (args->appl.cpu_count) + num_workers = args->appl.cpu_count; if (num_workers > MAX_WORKERS) num_workers = MAX_WORKERS; @@ -1234,11 +1234,11 @@ main(int argc, char *argv[]) odp_barrier_init(&sync_barrier, num_workers); /* - * By default core #0 runs Linux kernel background tasks. - * Start mapping thread from core #1 + * By default CPU #0 runs Linux kernel background tasks. + * Start mapping thread from CPU #1 */ - first_core = (1 == core_count) ? 0 : 1; - printf("First core: %i\n\n", first_core); + first_cpu = (1 == cpu_count) ? 0 : 1; + printf("First CPU: %i\n\n", first_cpu); /* Create packet buffer pool */ shm = odp_shm_reserve("shm_packet_pool", @@ -1304,7 +1304,7 @@ main(int argc, char *argv[]) /* * Create and init worker threads */ - odph_linux_pthread_create(thread_tbl, num_workers, first_core, + odph_linux_pthread_create(thread_tbl, num_workers, first_cpu, pktio_thread, NULL); /* @@ -1372,7 +1372,7 @@ static void parse_args(int argc, char *argv[], appl_args_t *appl_args) switch (opt) { case 'c': - appl_args->core_count = atoi(optarg); + appl_args->cpu_count = atoi(optarg); break; /* parse packet-io interface names */ case 'i': @@ -1479,10 +1479,10 @@ static void print_info(char *progname, appl_args_t *appl_args) "CPU model: %s\n" "CPU freq (hz): %"PRIu64"\n" "Cache line size: %i\n" - "Core count: %i\n" + "CPU count: %i\n" "\n", odp_version_api_str(), odp_sys_cpu_model_str(), odp_sys_cpu_hz(), - odp_sys_cache_line_size(), odp_sys_core_count()); + odp_sys_cache_line_size(), odp_sys_cpu_count()); printf("Running ODP appl: \"%s\"\n" "-----------------\n" @@ -1538,7 +1538,7 @@ static void usage(char *progname) " -a 192.168.111.2:192.168.222.2:md5:201:a731649644c5dee92cbd9c2e7e188ee6\n" "\n" "Optional OPTIONS\n" - " -c, --count Core count.\n" + " -c, --count CPU count.\n" " -h, --help Display help and exit.\n" " environment variables: ODP_PKTIO_DISABLE_SOCKET_MMAP\n" " ODP_PKTIO_DISABLE_SOCKET_MMSG\n" diff --git a/example/l2fwd/odp_l2fwd.c b/example/l2fwd/odp_l2fwd.c index ebac8c5..04bb863 100644 --- a/example/l2fwd/odp_l2fwd.c +++ b/example/l2fwd/odp_l2fwd.c @@ -66,7 +66,7 @@ * Parsed command line application arguments */ typedef struct { - int core_count; + int cpu_count; int if_count; /**< Number of interfaces to be used */ char **if_names; /**< Array of pointers to interface names */ int mode; /**< Packet IO mode */ @@ -316,8 +316,8 @@ int main(int argc, char *argv[]) odp_buffer_pool_t pool; void *pool_base; int i; - int first_core; - int core_count; + int first_cpu; + int cpu_count; odp_pktio_t pktio; odp_shm_t shm; @@ -350,11 +350,11 @@ int main(int argc, char *argv[]) /* Print both system and application information */ print_info(NO_PATH(argv[0]), &gbl_args->appl); - core_count = odp_sys_core_count(); - num_workers = core_count; + cpu_count = odp_sys_cpu_count(); + num_workers = cpu_count; - if (gbl_args->appl.core_count) - num_workers = gbl_args->appl.core_count; + if (gbl_args->appl.cpu_count) + num_workers = gbl_args->appl.cpu_count; if (num_workers > MAX_WORKERS) num_workers = MAX_WORKERS; @@ -362,7 +362,7 @@ int main(int argc, char *argv[]) printf("Num worker threads: %i\n", num_workers); if (num_workers < gbl_args->appl.if_count) { - EXAMPLE_ERR("Error: core count %d is less than interface " + EXAMPLE_ERR("Error: CPU count %d is less than interface " "count\n", num_workers); exit(EXIT_FAILURE); } @@ -372,15 +372,15 @@ int main(int argc, char *argv[]) exit(EXIT_FAILURE); } /* - * By default core #0 runs Linux kernel background tasks. - * Start mapping thread from core #1 + * By default CPU #0 runs Linux kernel background tasks. + * Start mapping thread from CPU #1 */ - first_core = 1; + first_cpu = 1; - if (core_count == 1) - first_core = 0; + if (cpu_count == 1) + first_cpu = 0; - printf("First core: %i\n\n", first_core); + printf("First cpu: %i\n\n", first_cpu); /* Create packet pool */ shm = odp_shm_reserve("shm_packet_pool", @@ -442,15 +442,15 @@ int main(int argc, char *argv[]) /* Create worker threads */ for (i = 0; i < num_workers; ++i) { void *(*thr_run_func) (void *); - int core; + int cpu; - core = (first_core + i) % core_count; + cpu = (first_cpu + i) % cpu_count; if (gbl_args->appl.mode == APPL_MODE_PKT_BURST) thr_run_func = pktio_ifburst_thread; else /* APPL_MODE_PKT_QUEUE */ thr_run_func = pktio_queue_thread; - odph_linux_pthread_create(&thread_tbl[i], 1, core, thr_run_func, + odph_linux_pthread_create(&thread_tbl[i], 1, cpu, thr_run_func, &gbl_args->thread[i]); } @@ -526,7 +526,7 @@ static void parse_args(int argc, char *argv[], appl_args_t *appl_args) switch (opt) { case 'c': - appl_args->core_count = atoi(optarg); + appl_args->cpu_count = atoi(optarg); break; /* parse packet-io interface names */ case 'i': @@ -611,10 +611,10 @@ static void print_info(char *progname, appl_args_t *appl_args) "CPU model: %s\n" "CPU freq (hz): %"PRIu64"\n" "Cache line size: %i\n" - "Core count: %i\n" + "CPU count: %i\n" "\n", odp_version_api_str(), odp_sys_cpu_model_str(), odp_sys_cpu_hz(), - odp_sys_cache_line_size(), odp_sys_core_count()); + odp_sys_cache_line_size(), odp_sys_cpu_count()); printf("Running ODP appl: \"%s\"\n" "-----------------\n" @@ -653,7 +653,7 @@ static void usage(char *progname) " 1: Send&receive packets through ODP queues.\n" "\n" "Optional OPTIONS\n" - " -c, --count Core count.\n" + " -c, --count CPU count.\n" " -h, --help Display help and exit.\n\n" " environment variables: ODP_PKTIO_DISABLE_SOCKET_MMAP\n" " ODP_PKTIO_DISABLE_SOCKET_MMSG\n" diff --git a/example/odp_example/odp_example.c b/example/odp_example/odp_example.c index 96a2912..8063991 100644 --- a/example/odp_example/odp_example.c +++ b/example/odp_example/odp_example.c @@ -48,7 +48,7 @@ typedef struct { /** Test arguments */ typedef struct { - int core_count; /**< Core count */ + int cpu_count; /**< CPU count */ int proc_mode; /**< Process mode */ } test_args_t; @@ -714,7 +714,7 @@ static void *run_thread(void *arg) thr = odp_thread_id(); - printf("Thread %i starts on core %i\n", thr, odp_thread_core()); + printf("Thread %i starts on CPU %i\n", thr, odp_thread_cpu()); shm = odp_shm_lookup("test_globals"); globals = odp_shm_addr(shm); @@ -893,7 +893,7 @@ static void print_usage(void) { printf("\n\nUsage: ./odp_example [options]\n"); printf("Options:\n"); - printf(" -c, --count core count, core IDs start from 1\n"); + printf(" -c, --count CPU count\n"); printf(" -h, --help this help\n"); printf(" --proc process mode\n"); printf("\n\n"); @@ -930,7 +930,7 @@ static void parse_args(int argc, char *argv[], test_args_t *args) break; case 'c': - args->core_count = atoi(optarg); + args->cpu_count = atoi(optarg); break; case 'h': @@ -958,7 +958,7 @@ int main(int argc, char *argv[]) odp_queue_t queue; int i, j; int prios; - int first_core; + int first_cpu; odp_shm_t shm; test_globals_t *globals; @@ -996,32 +996,32 @@ int main(int argc, char *argv[]) printf("CPU model: %s\n", odp_sys_cpu_model_str()); printf("CPU freq (hz): %"PRIu64"\n", odp_sys_cpu_hz()); printf("Cache line size: %i\n", odp_sys_cache_line_size()); - printf("Max core count: %i\n", odp_sys_core_count()); + printf("Max CPU count: %i\n", odp_sys_cpu_count()); printf("\n"); - /* A worker thread per core */ - num_workers = odp_sys_core_count(); + /* A worker thread per CPU */ + num_workers = odp_sys_cpu_count(); - if (args.core_count) - num_workers = args.core_count; + if (args.cpu_count) + num_workers = args.cpu_count; - /* force to max core count */ + /* force to max CPU count */ if (num_workers > MAX_WORKERS) num_workers = MAX_WORKERS; printf("num worker threads: %i\n", num_workers); /* - * By default core #0 runs Linux kernel background tasks. - * Start mapping thread from core #1 + * By default CPU #0 runs Linux kernel background tasks. + * Start mapping thread from CPU #1 */ - first_core = 1; + first_cpu = 1; - if (odp_sys_core_count() == 1) - first_core = 0; + if (odp_sys_cpu_count() == 1) + first_cpu = 0; - printf("first core: %i\n", first_core); + printf("first CPU: %i\n", first_cpu); /* Test cycle count accuracy */ @@ -1118,7 +1118,7 @@ int main(int argc, char *argv[]) /* Fork worker processes */ ret = odph_linux_process_fork_n(proc, num_workers, - first_core); + first_cpu); if (ret < 0) { EXAMPLE_ERR("Fork workers failed %i\n", ret); @@ -1136,7 +1136,7 @@ int main(int argc, char *argv[]) } else { /* Create and launch worker threads */ - odph_linux_pthread_create(thread_tbl, num_workers, first_core, + odph_linux_pthread_create(thread_tbl, num_workers, first_cpu, run_thread, NULL); /* Wait for worker threads to terminate */ diff --git a/example/packet/odp_pktio.c b/example/packet/odp_pktio.c index 607ecbf..277bd24 100644 --- a/example/packet/odp_pktio.c +++ b/example/packet/odp_pktio.c @@ -66,7 +66,7 @@ * Parsed command line application arguments */ typedef struct { - int core_count; + int cpu_count; int if_count; /**< Number of interfaces to be used */ char **if_names; /**< Array of pointers to interface names */ int mode; /**< Packet IO mode */ @@ -333,8 +333,8 @@ int main(int argc, char *argv[]) int num_workers; void *pool_base; int i; - int first_core; - int core_count; + int first_cpu; + int cpu_count; odp_shm_t shm; args = calloc(1, sizeof(args_t)); @@ -361,11 +361,11 @@ int main(int argc, char *argv[]) /* Print both system and application information */ print_info(NO_PATH(argv[0]), &args->appl); - core_count = odp_sys_core_count(); - num_workers = core_count; + cpu_count = odp_sys_cpu_count(); + num_workers = cpu_count; - if (args->appl.core_count) - num_workers = args->appl.core_count; + if (args->appl.cpu_count) + num_workers = args->appl.cpu_count; if (num_workers > MAX_WORKERS) num_workers = MAX_WORKERS; @@ -373,15 +373,15 @@ int main(int argc, char *argv[]) printf("Num worker threads: %i\n", num_workers); /* - * By default core #0 runs Linux kernel background tasks. - * Start mapping thread from core #1 + * By default CPU #0 runs Linux kernel background tasks. + * Start mapping thread from CPU #1 */ - first_core = 1; + first_cpu = 1; - if (core_count == 1) - first_core = 0; + if (cpu_count == 1) + first_cpu = 0; - printf("First core: %i\n\n", first_core); + printf("First CPU: %i\n\n", first_cpu); /* Create packet pool */ shm = odp_shm_reserve("shm_packet_pool", @@ -408,10 +408,10 @@ int main(int argc, char *argv[]) memset(thread_tbl, 0, sizeof(thread_tbl)); for (i = 0; i < num_workers; ++i) { void *(*thr_run_func) (void *); - int core; + int cpu; int if_idx; - core = (first_core + i) % core_count; + cpu = (first_cpu + i) % cpu_count; if_idx = i % args->appl.if_count; @@ -429,7 +429,7 @@ int main(int argc, char *argv[]) * because each thread might get different arguments. * Calls odp_thread_create(cpu) for each thread */ - odph_linux_pthread_create(&thread_tbl[i], 1, core, thr_run_func, + odph_linux_pthread_create(&thread_tbl[i], 1, cpu, thr_run_func, &args->thread[i]); } @@ -545,7 +545,7 @@ static void parse_args(int argc, char *argv[], appl_args_t *appl_args) switch (opt) { case 'c': - appl_args->core_count = atoi(optarg); + appl_args->cpu_count = atoi(optarg); break; /* parse packet-io interface names */ case 'i': @@ -633,10 +633,10 @@ static void print_info(char *progname, appl_args_t *appl_args) "CPU model: %s\n" "CPU freq (hz): %"PRIu64"\n" "Cache line size: %i\n" - "Core count: %i\n" + "CPU count: %i\n" "\n", odp_version_api_str(), odp_sys_cpu_model_str(), odp_sys_cpu_hz(), - odp_sys_cache_line_size(), odp_sys_core_count()); + odp_sys_cache_line_size(), odp_sys_cpu_count()); printf("Running ODP appl: \"%s\"\n" "-----------------\n" @@ -672,7 +672,7 @@ static void usage(char *progname) " 1: Send&receive packets through ODP queues.\n" "\n" "Optional OPTIONS\n" - " -c, --count Core count.\n" + " -c, --count CPU count.\n" " -h, --help Display help and exit.\n" " -t, --mtu MTU\n" " environment variables: ODP_PKTIO_DISABLE_SOCKET_MMAP\n" diff --git a/example/timer/odp_timer_test.c b/example/timer/odp_timer_test.c index 9968bfe..009b759 100644 --- a/example/timer/odp_timer_test.c +++ b/example/timer/odp_timer_test.c @@ -31,7 +31,7 @@ /** Test arguments */ typedef struct { - int core_count; /**< Core count*/ + int cpu_count; /**< CPU count*/ int resolution_us; /**< Timeout resolution in usec*/ int min_us; /**< Minimum timeout in usec*/ int max_us; /**< Maximum timeout in usec*/ @@ -125,7 +125,7 @@ static void *run_thread(void *ptr) args = ptr; thr = odp_thread_id(); - printf("Thread %i starts on core %i\n", thr, odp_thread_core()); + printf("Thread %i starts on cpu %i\n", thr, odp_thread_cpu()); /* * Find the buffer pool @@ -155,7 +155,7 @@ static void print_usage(void) { printf("\n\nUsage: ./odp_example [options]\n"); printf("Options:\n"); - printf(" -c, --count core count, core IDs start from 1\n"); + printf(" -c, --count CPU count\n"); printf(" -r, --resolution timeout resolution in usec\n"); printf(" -m, --min minimum timeout in usec\n"); printf(" -x, --max maximum timeout in usec\n"); @@ -190,7 +190,7 @@ static void parse_args(int argc, char *argv[], test_args_t *args) }; /* defaults */ - args->core_count = 0; /* all cores */ + args->cpu_count = 0; /* all CPU's */ args->resolution_us = 10000; args->min_us = args->resolution_us; args->max_us = 10000000; @@ -206,7 +206,7 @@ static void parse_args(int argc, char *argv[], test_args_t *args) switch (opt) { case 'c': - args->core_count = atoi(optarg); + args->cpu_count = atoi(optarg); break; case 'r': args->resolution_us = atoi(optarg); @@ -246,7 +246,7 @@ int main(int argc, char *argv[]) odp_buffer_pool_t pool; void *pool_base; odp_queue_t queue; - int first_core; + int first_cpu; uint64_t cycles, ns; odp_queue_param_t param; odp_shm_t shm; @@ -276,32 +276,32 @@ int main(int argc, char *argv[]) printf("CPU model: %s\n", odp_sys_cpu_model_str()); printf("CPU freq (hz): %"PRIu64"\n", odp_sys_cpu_hz()); printf("Cache line size: %i\n", odp_sys_cache_line_size()); - printf("Max core count: %i\n", odp_sys_core_count()); + printf("Max CPU count: %i\n", odp_sys_cpu_count()); printf("\n"); - /* A worker thread per core */ - num_workers = odp_sys_core_count(); + /* A worker thread per CPU */ + num_workers = odp_sys_cpu_count(); - if (args.core_count) - num_workers = args.core_count; + if (args.cpu_count) + num_workers = args.cpu_count; - /* force to max core count */ + /* force to max CPU count */ if (num_workers > MAX_WORKERS) num_workers = MAX_WORKERS; printf("num worker threads: %i\n", num_workers); /* - * By default core #0 runs Linux kernel background tasks. - * Start mapping thread from core #1 + * By default CPU #0 runs Linux kernel background tasks. + * Start mapping thread from CPU #1 */ - first_core = 1; + first_cpu = 1; - if (odp_sys_core_count() == 1) - first_core = 0; + if (odp_sys_cpu_count() == 1) + first_cpu = 0; - printf("first core: %i\n", first_core); + printf("first CPU: %i\n", first_cpu); printf("resolution: %i usec\n", args.resolution_us); printf("min timeout: %i usec\n", args.min_us); printf("max timeout: %i usec\n", args.max_us); @@ -377,7 +377,7 @@ int main(int argc, char *argv[]) odp_barrier_init(&test_barrier, num_workers); /* Create and launch worker threads */ - odph_linux_pthread_create(thread_tbl, num_workers, first_core, + odph_linux_pthread_create(thread_tbl, num_workers, first_cpu, run_thread, &args); /* Wait for worker threads to exit */ diff --git a/helper/include/odph_linux.h b/helper/include/odph_linux.h index 8671dc0..4ed8bbe 100644 --- a/helper/include/odph_linux.h +++ b/helper/include/odph_linux.h @@ -30,14 +30,14 @@ extern "C" { typedef struct { pthread_t thread; /**< Pthread ID */ pthread_attr_t attr; /**< Pthread attributes */ - int core; /**< Core ID */ + int cpu; /**< CPU ID */ } odph_linux_pthread_t; /** Linux process state information */ typedef struct { pid_t pid; /**< Process ID */ - int core; /**< Core ID */ + int cpu; /**< CPU ID */ int status; /**< Process state change status */ } odph_linux_process_t; @@ -45,17 +45,17 @@ typedef struct { /** * Creates and launches pthreads * - * Creates, pins and launches num threads to separate cores starting from - * first_core. + * Creates, pins and launches num threads to separate CPU's starting from + * first_cpu. * * @param thread_tbl Thread table * @param num Number of threads to create - * @param first_core First physical core + * @param first_cpu First physical CPU * @param start_routine Thread start function * @param arg Thread argument */ void odph_linux_pthread_create(odph_linux_pthread_t *thread_tbl, - int num, int first_core, + int num, int first_cpu, void *(*start_routine) (void *), void *arg); @@ -74,31 +74,31 @@ void odph_linux_pthread_join(odph_linux_pthread_t *thread_tbl, int num); /** * Fork a process * - * Forks and sets core affinity for the child process + * Forks and sets CPU affinity for the child process * * @param proc Pointer to process state info (for output) - * @param core Destination core for the child process + * @param cpu Destination CPU for the child process * * @return On success: 1 for the parent, 0 for the child * On failure: -1 for the parent, -2 for the child */ -int odph_linux_process_fork(odph_linux_process_t *proc, int core); +int odph_linux_process_fork(odph_linux_process_t *proc, int cpu); /** * Fork a number of processes * - * Forks and sets core affinity for child processes + * Forks and sets CPU affinity for child processes * * @param proc_tbl Process state info table (for output) * @param num Number of processes to create - * @param first_core Destination core for the first process + * @param first_cpu Destination CPU for the first process * * @return On success: 1 for the parent, 0 for the child * On failure: -1 for the parent, -2 for the child */ int odph_linux_process_fork_n(odph_linux_process_t *proc_tbl, - int num, int first_core); + int num, int first_cpu); /** diff --git a/platform/linux-generic/include/api/odp_system_info.h b/platform/linux-generic/include/api/odp_system_info.h index bcd08d7..42ab054 100644 --- a/platform/linux-generic/include/api/odp_system_info.h +++ b/platform/linux-generic/include/api/odp_system_info.h @@ -61,11 +61,13 @@ const char *odp_sys_cpu_model_str(void); int odp_sys_cache_line_size(void); /** - * Core count + * CPU count + * Report the number of CPU's available to this ODP program. + * This may be smaller than the number of (online) CPU's in the system. * - * @return Core count + * @return Number of available CPU's */ -int odp_sys_core_count(void); +int odp_sys_cpu_count(void); /** * @} diff --git a/platform/linux-generic/include/api/odp_thread.h b/platform/linux-generic/include/api/odp_thread.h index 2b7177d..469d298 100644 --- a/platform/linux-generic/include/api/odp_thread.h +++ b/platform/linux-generic/include/api/odp_thread.h @@ -31,11 +31,11 @@ int odp_thread_id(void); /** - * Get core id + * Get CPU number * - * @return Core id where the thread is running currently + * @return CPU ID where the thread is currently running */ -int odp_thread_core(void); +int odp_thread_cpu(void); /** * @} diff --git a/platform/linux-generic/odp_linux.c b/platform/linux-generic/odp_linux.c index ecd77b3..cece413 100644 --- a/platform/linux-generic/odp_linux.c +++ b/platform/linux-generic/odp_linux.c @@ -48,27 +48,27 @@ static void *odp_run_start_routine(void *arg) void odph_linux_pthread_create(odph_linux_pthread_t *thread_tbl, int num, - int first_core, + int first_cpu, void *(*start_routine) (void *), void *arg) { int i; cpu_set_t cpu_set; odp_start_args_t *start_args; - int core_count; + int cpu_count; int cpu; - core_count = odp_sys_core_count(); + cpu_count = odp_sys_cpu_count(); - assert((first_core >= 0) && (first_core < core_count)); - assert((num >= 0) && (num <= core_count)); + assert((first_cpu >= 0) && (first_cpu < cpu_count)); + assert((num >= 0) && (num <= cpu_count)); memset(thread_tbl, 0, num * sizeof(odph_linux_pthread_t)); for (i = 0; i < num; i++) { pthread_attr_init(&thread_tbl[i].attr); - cpu = (first_core + i) % core_count; - thread_tbl[i].core = cpu; + cpu = (first_cpu + i) % cpu_count; + thread_tbl[i].cpu = cpu; CPU_ZERO(&cpu_set); CPU_SET(cpu, &cpu_set); @@ -101,30 +101,30 @@ void odph_linux_pthread_join(odph_linux_pthread_t *thread_tbl, int num) int odph_linux_process_fork_n(odph_linux_process_t *proc_tbl, - int num, int first_core) + int num, int first_cpu) { cpu_set_t cpu_set; pid_t pid; - int core_count; + int cpu_count; int cpu; int i; memset(proc_tbl, 0, num*sizeof(odph_linux_process_t)); - core_count = odp_sys_core_count(); + cpu_count = odp_sys_cpu_count(); - if (first_core < 0 || first_core >= core_count) { - ODP_ERR("Bad first_core\n"); + if (first_cpu < 0 || first_cpu >= cpu_count) { + ODP_ERR("Bad first_cpu\n"); return -1; } - if (num < 0 || num > core_count) { + if (num < 0 || num > cpu_count) { ODP_ERR("Bad num\n"); return -1; } for (i = 0; i < num; i++) { - cpu = (first_core + i) % core_count; + cpu = (first_cpu + i) % cpu_count; pid = fork(); if (pid < 0) { @@ -135,7 +135,7 @@ int odph_linux_process_fork_n(odph_linux_process_t *proc_tbl, /* Parent continues to fork */ if (pid > 0) { proc_tbl[i].pid = pid; - proc_tbl[i].core = cpu; + proc_tbl[i].cpu = cpu; continue; } @@ -160,9 +160,9 @@ int odph_linux_process_fork_n(odph_linux_process_t *proc_tbl, } -int odph_linux_process_fork(odph_linux_process_t *proc, int core) +int odph_linux_process_fork(odph_linux_process_t *proc, int cpu) { - return odph_linux_process_fork_n(proc, 1, core); + return odph_linux_process_fork_n(proc, 1, cpu); } diff --git a/platform/linux-generic/odp_system_info.c b/platform/linux-generic/odp_system_info.c index 7d18573..aab3f6f 100644 --- a/platform/linux-generic/odp_system_info.c +++ b/platform/linux-generic/odp_system_info.c @@ -24,7 +24,7 @@ typedef struct { uint64_t huge_page_size; uint64_t page_size; int cache_line_size; - int core_count; + int cpu_count; char model_str[128]; } odp_system_info_t; @@ -45,9 +45,9 @@ static odp_system_info_t odp_system_info; /* - * Sysconf + * Report the number of online CPU's */ -static int sysconf_core_count(void) +static int sysconf_cpu_count(void) { long ret; @@ -287,13 +287,13 @@ static int systemcpu(odp_system_info_t *sysinfo) { int ret; - ret = sysconf_core_count(); + ret = sysconf_cpu_count(); if (ret == 0) { - ODP_ERR("sysconf_core_count failed.\n"); + ODP_ERR("sysconf_cpu_count failed.\n"); return -1; } - sysinfo->core_count = ret; + sysinfo->cpu_count = ret; ret = systemcpu_cache_line_size(); @@ -325,13 +325,13 @@ static int systemcpu(odp_system_info_t *sysinfo) { int ret; - ret = sysconf_core_count(); + ret = sysconf_cpu_count(); if (ret == 0) { - ODP_ERR("sysconf_core_count failed.\n"); + ODP_ERR("sysconf_cpu_count failed.\n"); return -1; } - sysinfo->core_count = ret; + sysinfo->cpu_count = ret; /* Dummy values */ sysinfo->cpu_hz = 1400000000; @@ -403,7 +403,7 @@ int odp_sys_cache_line_size(void) return odp_system_info.cache_line_size; } -int odp_sys_core_count(void) +int odp_sys_cpu_count(void) { - return odp_system_info.core_count; + return odp_system_info.cpu_count; } diff --git a/platform/linux-generic/odp_thread.c b/platform/linux-generic/odp_thread.c index faa12a2..192e5d1 100644 --- a/platform/linux-generic/odp_thread.c +++ b/platform/linux-generic/odp_thread.c @@ -108,7 +108,7 @@ int odp_thread_id(void) } -int odp_thread_core(void) +int odp_thread_cpu(void) { return this_thread->cpu; } diff --git a/test/api_test/odp_atomic_test.c b/test/api_test/odp_atomic_test.c index 5563606..ec4a8d8 100644 --- a/test/api_test/odp_atomic_test.c +++ b/test/api_test/odp_atomic_test.c @@ -37,7 +37,7 @@ static void usage(void) "\t\t5 - Test add/sub of 64-bit atomic int\n" "\t\t-n <1 - 31> - no of threads to start\n" "\t\tif user doesn't specify this option, then\n" - "\t\tno of threads created is equivalent to no of cores\n" + "\t\tno of threads created is equivalent to no of CPU's\n" "\t\tavailable in the system\n" "\tExample usage:\n" "\t\t./odp_atomic -t 2\n" @@ -254,7 +254,7 @@ int main(int argc, char *argv[]) goto err_exit; } if (test_type < TEST_MIX || test_type > TEST_MAX || - pthrdnum > odp_sys_core_count() || pthrdnum < 0) { + pthrdnum > odp_sys_cpu_count() || pthrdnum < 0) { usage(); goto err_exit; } @@ -262,7 +262,7 @@ int main(int argc, char *argv[]) } if (pthrdnum == 0) - pthrdnum = odp_sys_core_count(); + pthrdnum = odp_sys_cpu_count(); test_atomic_init(); test_atomic_store(); diff --git a/test/api_test/odp_common.c b/test/api_test/odp_common.c index 329d4d4..e585ef5 100644 --- a/test/api_test/odp_common.c +++ b/test/api_test/odp_common.c @@ -46,8 +46,8 @@ void odp_print_system_info(void) printf("CPU model: %s\n", odp_sys_cpu_model_str()); printf("CPU freq (hz): %"PRIu64"\n", odp_sys_cpu_hz()); printf("Cache line size: %i\n", odp_sys_cache_line_size()); - printf("Core count: %i\n", odp_sys_core_count()); - printf("Core mask: %s\n", str); + printf("CPU count: %i\n", odp_sys_cpu_count()); + printf("CPU mask: %s\n", str); printf("\n"); } @@ -62,8 +62,8 @@ int odp_test_global_init(void) return -1; } - num_workers = odp_sys_core_count(); - /* force to max core count */ + num_workers = odp_sys_cpu_count(); + /* force to max CPU count */ if (num_workers > MAX_WORKERS) num_workers = MAX_WORKERS; diff --git a/test/api_test/odp_ring_test.c b/test/api_test/odp_ring_test.c index 54398f0..e3d7b4e 100644 --- a/test/api_test/odp_ring_test.c +++ b/test/api_test/odp_ring_test.c @@ -430,7 +430,7 @@ int main(int argc __attribute__((__unused__)), odph_ring_tailq_init(); - rarg.thrdarg.numthrds = odp_sys_core_count(); + rarg.thrdarg.numthrds = odp_sys_cpu_count(); #ifdef RING_TEST_BASIC rarg.thrdarg.testcase = ODP_RING_TEST_BASIC; diff --git a/test/api_test/odp_shm_test.c b/test/api_test/odp_shm_test.c index 5163337..be83657 100644 --- a/test/api_test/odp_shm_test.c +++ b/test/api_test/odp_shm_test.c @@ -58,7 +58,7 @@ int main(int argc __attribute__((__unused__)), printf("test shared data at %p\n\n", test_shared_data); thrdarg.testcase = ODP_SHM_TEST; - thrdarg.numthrds = odp_sys_core_count(); + thrdarg.numthrds = odp_sys_cpu_count(); odp_test_thread_create(run_thread, &thrdarg); odp_test_thread_exit(&thrdarg);