From patchwork Thu Oct 5 12:33:13 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Li, Xiaoyun" X-Patchwork-Id: 29690 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id EE9331B199; Thu, 5 Oct 2017 14:35:07 +0200 (CEST) Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by dpdk.org (Postfix) with ESMTP id 8818237B1 for ; Thu, 5 Oct 2017 14:35:03 +0200 (CEST) Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 05 Oct 2017 05:35:03 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.42,481,1500966000"; d="scan'208";a="135502582" Received: from dpdk-lixiaoyun.sh.intel.com ([10.67.111.93]) by orsmga004.jf.intel.com with ESMTP; 05 Oct 2017 05:35:01 -0700 From: Xiaoyun Li To: konstantin.ananyev@intel.com, bruce.richardson@intel.com Cc: wenzhuo.lu@intel.com, helin.zhang@intel.com, dev@dpdk.org, Xiaoyun Li Date: Thu, 5 Oct 2017 20:33:13 +0800 Message-Id: <1507206794-79941-3-git-send-email-xiaoyun.li@intel.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1507206794-79941-1-git-send-email-xiaoyun.li@intel.com> References: <1507157911-8702-1-git-send-email-xiaoyun.li@intel.com> <1507206794-79941-1-git-send-email-xiaoyun.li@intel.com> Subject: [dpdk-dev] [PATCH v7 2/3] app/test: run-time dispatch over memcpy perf test X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" This patch modifies assignment of alignment unit from build-time to run-time based on CPU flags that machine supports. Signed-off-by: Xiaoyun Li --- test/test/test_memcpy_perf.c | 40 +++++++++++++++++++++++++++------------- 1 file changed, 27 insertions(+), 13 deletions(-) diff --git a/test/test/test_memcpy_perf.c b/test/test/test_memcpy_perf.c index ff3aaaa..33def3b 100644 --- a/test/test/test_memcpy_perf.c +++ b/test/test/test_memcpy_perf.c @@ -79,13 +79,7 @@ static size_t buf_sizes[TEST_VALUE_RANGE]; #define TEST_BATCH_SIZE 100 /* Data is aligned on this many bytes (power of 2) */ -#ifdef RTE_MACHINE_CPUFLAG_AVX512F -#define ALIGNMENT_UNIT 64 -#elif defined RTE_MACHINE_CPUFLAG_AVX2 -#define ALIGNMENT_UNIT 32 -#else /* RTE_MACHINE_CPUFLAG */ -#define ALIGNMENT_UNIT 16 -#endif /* RTE_MACHINE_CPUFLAG */ +static uint8_t alignment_unit = 16; /* * Pointers used in performance tests. The two large buffers are for uncached @@ -100,20 +94,39 @@ static int init_buffers(void) { unsigned i; +#ifdef CC_SUPPORT_AVX512 + if (rte_cpu_get_flag_enabled(RTE_CPUFLAG_AVX512F)) + alignment_unit = 64; + else +#endif +#ifdef CC_SUPPORT_AVX2 + if (rte_cpu_get_flag_enabled(RTE_CPUFLAG_AVX2)) + alignment_unit = 32; + else +#endif + alignment_unit = 16; - large_buf_read = rte_malloc("memcpy", LARGE_BUFFER_SIZE + ALIGNMENT_UNIT, ALIGNMENT_UNIT); + large_buf_read = rte_malloc("memcpy", + LARGE_BUFFER_SIZE + alignment_unit, + alignment_unit); if (large_buf_read == NULL) goto error_large_buf_read; - large_buf_write = rte_malloc("memcpy", LARGE_BUFFER_SIZE + ALIGNMENT_UNIT, ALIGNMENT_UNIT); + large_buf_write = rte_malloc("memcpy", + LARGE_BUFFER_SIZE + alignment_unit, + alignment_unit); if (large_buf_write == NULL) goto error_large_buf_write; - small_buf_read = rte_malloc("memcpy", SMALL_BUFFER_SIZE + ALIGNMENT_UNIT, ALIGNMENT_UNIT); + small_buf_read = rte_malloc("memcpy", + SMALL_BUFFER_SIZE + alignment_unit, + alignment_unit); if (small_buf_read == NULL) goto error_small_buf_read; - small_buf_write = rte_malloc("memcpy", SMALL_BUFFER_SIZE + ALIGNMENT_UNIT, ALIGNMENT_UNIT); + small_buf_write = rte_malloc("memcpy", + SMALL_BUFFER_SIZE + alignment_unit, + alignment_unit); if (small_buf_write == NULL) goto error_small_buf_write; @@ -153,7 +166,7 @@ static inline size_t get_rand_offset(size_t uoffset) { return ((rte_rand() % (LARGE_BUFFER_SIZE - SMALL_BUFFER_SIZE)) & - ~(ALIGNMENT_UNIT - 1)) + uoffset; + ~(alignment_unit - 1)) + uoffset; } /* Fill in source and destination addresses. */ @@ -321,7 +334,8 @@ perf_test(void) "(bytes) (ticks) (ticks) (ticks) (ticks)\n" "------- -------------- -------------- -------------- --------------"); - printf("\n========================== %2dB aligned ============================", ALIGNMENT_UNIT); + printf("\n========================= %2dB aligned ============================", + alignment_unit); /* Do aligned tests where size is a variable */ perf_test_variable_aligned(); printf("\n------- -------------- -------------- -------------- --------------");