From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by dpdk.org (Postfix) with ESMTP id 6EF532A5B for ; Mon, 2 Feb 2015 06:16:07 +0100 (CET) Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga102.jf.intel.com with ESMTP; 01 Feb 2015 21:12:24 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.09,504,1418112000"; d="scan'208";a="645982269" Received: from shwdeisgchi017.ccr.corp.intel.com (HELO [10.239.66.47]) ([10.239.66.47]) by orsmga001.jf.intel.com with ESMTP; 01 Feb 2015 21:15:49 -0800 Message-ID: <54CF0805.8040103@intel.com> Date: Mon, 02 Feb 2015 13:15:49 +0800 From: "Liang, Cunming" User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:31.0) Gecko/20100101 Thunderbird/31.4.0 MIME-Version: 1.0 To: Yerden Zhumabekov , dev@dpdk.org References: <1409724351-23786-1-git-send-email-e_zhumabekov@sts.kz> <3fdc339aa3f0206ae2200937b9791af69e83409e.1417092208.git.e_zhumabekov@sts.kz> In-Reply-To: <3fdc339aa3f0206ae2200937b9791af69e83409e.1417092208.git.e_zhumabekov@sts.kz> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [dpdk-dev] [PATCH v6 2/7] hash: add assembly implementation of CRC32 intrinsics X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 02 Feb 2015 05:16:08 -0000 On 1/29/2015 4:48 PM, Yerden Zhumabekov wrote: > Added: > - crc32c_sse42_u32() emits 'crc32l' asm instruction; > - crc32c_sse42_u64() emits 'crc32q' asm instruction; > - crc32c_sse42_u64_mimic(), wrapper in case of run on 32-bit platform. > > Signed-off-by: Yerden Zhumabekov > --- > lib/librte_hash/rte_hash_crc.h | 34 ++++++++++++++++++++++++++++++++++ > 1 file changed, 34 insertions(+) > > diff --git a/lib/librte_hash/rte_hash_crc.h b/lib/librte_hash/rte_hash_crc.h > index 4da7ca4..fe35996 100644 > --- a/lib/librte_hash/rte_hash_crc.h > +++ b/lib/librte_hash/rte_hash_crc.h > @@ -363,6 +363,40 @@ crc32c_2words(uint64_t data, uint32_t init_val) > return crc; > } > > +static inline uint32_t > +crc32c_sse42_u32(uint32_t data, uint32_t init_val) > +{ > + __asm__ volatile( > + "crc32l %[data], %[init_val];" > + : [init_val] "+r" (init_val) > + : [data] "rm" (data)); > + return init_val; > +} > + > +static inline uint32_t > +crc32c_sse42_u64(uint64_t data, uint64_t init_val) > +{ > + __asm__ volatile( > + "crc32q %[data], %[init_val];" > + : [init_val] "+r" (init_val) > + : [data] "rm" (data)); > + return init_val; > +} [LCM] I'm curious about the benefit of replacing CRC32 intrinsic "_mm_crc32_u32/64". > + > +static inline uint32_t > +crc32c_sse42_u64_mimic(uint64_t data, uint64_t init_val) > +{ > + union { > + uint32_t u32[2]; > + uint64_t u64; > + } d; > + > + d.u64 = data; > + init_val = crc32c_sse42_u32(d.u32[0], init_val); > + init_val = crc32c_sse42_u32(d.u32[1], init_val); > + return init_val; > +} > + > /** > * Use single crc32 instruction to perform a hash on a 4 byte value. > *