From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Liang, Cunming" Subject: Re: [PATCH v6 2/7] hash: add assembly implementation of CRC32 intrinsics Date: Mon, 02 Feb 2015 13:15:49 +0800 Message-ID: <54CF0805.8040103@intel.com> References: <1409724351-23786-1-git-send-email-e_zhumabekov@sts.kz> <3fdc339aa3f0206ae2200937b9791af69e83409e.1417092208.git.e_zhumabekov@sts.kz> Mime-Version: 1.0 Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit To: Yerden Zhumabekov , dev-VfR2kkLFssw@public.gmane.org Return-path: In-Reply-To: <3fdc339aa3f0206ae2200937b9791af69e83409e.1417092208.git.e_zhumabekov-8EHiFRVJVgQ@public.gmane.org> List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces-VfR2kkLFssw@public.gmane.org Sender: "dev" 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. > *