From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-oi1-x22c.google.com (mail-oi1-x22c.google.com [IPv6:2607:f8b0:4864:20::22c]) by sourceware.org (Postfix) with ESMTPS id C049D3982402 for ; Mon, 11 Jul 2022 22:32:35 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org C049D3982402 Received: by mail-oi1-x22c.google.com with SMTP id w184so2172014oie.3 for ; Mon, 11 Jul 2022 15:32:35 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=PAm2C1xn5G737LUyDc6Ukk/OO+NK4ivPMk1hcf+FNao=; b=kn38hatpT+TmJyG2Kru4TgpZddwBNy4SXajrMz4On59hyd7WpC8iQP8+OR81o6fB6I H0Kk9nYYxSgHR1bEAvbrkvoNhPBvIEB4OR3kq3uBgYN2xR+/eheh62UqyqLDPpA5sG04 R0xUi+4dccbVMbAgpWxgGpNJSo+jzZS1BCSmrifLyB2X54STAKrVncYA/mtBsY6ETRh3 HAGQXFLfgge5wKoAteZ8QsQf4+pw43nwC29VfLJgtFDo1Z9nqSOFa8qUDivOMoI6QQKD IZOY7DvnE6BmN3LCepxdCNtUKXs4twTlGvOCALx5YSrb1Ho1cU0VrXM6Za9SF/O1vVW2 g5wQ== X-Gm-Message-State: AJIora8c3m5U6SEF4nvcSwl47z15lMDsvrFWAwdOz5E6jD/iMzwSGhx5 55XMUEGujT/MYYEanBeA7gWur6NzObBYUZGNTeMOYyoK X-Google-Smtp-Source: AGRyM1vo7a4GpR1hW/Aimsra42473D1g5nGedpWyLx5UeU9+OJG90zSz3lLH9C/SX21Y3/taBij2N2ufP3e0EYe2x6w= X-Received: by 2002:aca:2104:0:b0:339:f97b:1028 with SMTP id 4-20020aca2104000000b00339f97b1028mr354984oiz.175.1657578755098; Mon, 11 Jul 2022 15:32:35 -0700 (PDT) MIME-Version: 1.0 References: <20220711220730.1968923-1-goldstein.w.n@gmail.com> In-Reply-To: From: Noah Goldstein Date: Mon, 11 Jul 2022 15:32:24 -0700 Message-ID: Subject: Re: [PATCH v1] x86: Use regular casting instead of _cvtmask64_u64 in strstr-avx512 To: Sunil Pandey Cc: GNU C Library , "H.J. Lu" , "Carlos O'Donell" Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-9.3 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, KAM_NUMSUBJECT, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 11 Jul 2022 22:32:38 -0000 On Mon, Jul 11, 2022 at 3:18 PM Sunil Pandey wrote: > > On Mon, Jul 11, 2022 at 3:08 PM Noah Goldstein wrote: > > > > On Mon, Jul 11, 2022 at 3:07 PM Noah Goldstein wrote: > > > > > > _cvtmask64_u64 is not available before GCC7. > > > --- > > > sysdeps/x86_64/multiarch/strstr-avx512.c | 12 +++++++----- > > > 1 file changed, 7 insertions(+), 5 deletions(-) > > > > > > diff --git a/sysdeps/x86_64/multiarch/strstr-avx512.c b/sysdeps/x86_64/multiarch/strstr-avx512.c > > > index 2ab9e96db8..e41b44abe1 100644 > > > --- a/sysdeps/x86_64/multiarch/strstr-avx512.c > > > +++ b/sysdeps/x86_64/multiarch/strstr-avx512.c > > > @@ -26,6 +26,8 @@ > > > #define ZMM_SIZE_IN_BYTES 64 > > > #define PAGESIZE 4096 > > > > > > +#define cvtmask64_u64(...) (uint64_t) (__VA_ARGS__) > > > + > > > /* > > > Returns the index of the first edge within the needle, returns 0 if no edge > > > is found. Example: 'ab' is the first edge in 'aaaaaaaaaabaarddg' > > > @@ -133,15 +135,15 @@ __strstr_avx512 (const char *haystack, const char *ned) > > > __m512i hay0 = _mm512_maskz_loadu_epi8 (loadmask, haystack + hay_index); > > > /* Search for NULL and compare only till null char */ > > > uint64_t nullmask > > > - = _cvtmask64_u64 (_mm512_mask_testn_epi8_mask (loadmask, hay0, hay0)); > > > + = cvtmask64_u64 (_mm512_mask_testn_epi8_mask (loadmask, hay0, hay0)); > > > uint64_t cmpmask = nullmask ^ (nullmask - ONE_64BIT); > > > - cmpmask = cmpmask & _cvtmask64_u64 (loadmask); > > > + cmpmask = cmpmask & cvtmask64_u64 (loadmask); > > > /* Search for the 2 charaters of needle */ > > > __mmask64 k0 = _mm512_cmpeq_epi8_mask (hay0, ned0); > > > __mmask64 k1 = _mm512_cmpeq_epi8_mask (hay0, ned1); > > > k1 = _kshiftri_mask64 (k1, 1); > > > /* k2 masks tell us if both chars from needle match */ > > > - uint64_t k2 = _cvtmask64_u64 (_kand_mask64 (k0, k1)) & cmpmask; > > > + uint64_t k2 = cvtmask64_u64 (_kand_mask64 (k0, k1)) & cmpmask; > > > /* For every match, search for the entire needle for a full match */ > > > while (k2) > > > { > > > @@ -178,13 +180,13 @@ __strstr_avx512 (const char *haystack, const char *ned) > > > hay0 = _mm512_loadu_si512 (haystack + hay_index); > > > hay1 = _mm512_load_si512 (haystack + hay_index > > > + 1); // Always 64 byte aligned > > > - nullmask = _cvtmask64_u64 (_mm512_testn_epi8_mask (hay1, hay1)); > > > + nullmask = cvtmask64_u64 (_mm512_testn_epi8_mask (hay1, hay1)); > > > /* Compare only till null char */ > > > cmpmask = nullmask ^ (nullmask - ONE_64BIT); > > > k0 = _mm512_cmpeq_epi8_mask (hay0, ned0); > > > k1 = _mm512_cmpeq_epi8_mask (hay1, ned1); > > > /* k2 masks tell us if both chars from needle match */ > > > - k2 = _cvtmask64_u64 (_kand_mask64 (k0, k1)) & cmpmask; > > > + k2 = cvtmask64_u64 (_kand_mask64 (k0, k1)) & cmpmask; > > > /* For every match, compare full strings for potential match */ > > > while (k2) > > > { > > > -- > > > 2.34.1 > > > > > > > Sunil, can you see if this fixed the build issue with gcc6? > > Nope, there are more missing intrinsics > > ../sysdeps/x86_64/multiarch/strstr-avx512.c:144:8: error: implicit > declaration of function ?_kshiftri_mask64? [-Wer > ror=implicit-function-declaration] > ../sysdeps/x86_64/multiarch/strstr-avx512.c:146:32: error: implicit > declaration of function ?_kand_mask64? [-Werror > =implicit-function-declaration] > ../sysdeps/x86_64/multiarch/strstr-avx512.c:144:8: error: implicit > declaration of function ?_kshiftri_mask64? [-Wer > ror=implicit-function-declaration] > ../sysdeps/x86_64/multiarch/strstr-avx512.c:146:32: error: implicit > declaration of function ?_kand_mask64? [-Werror > =implicit-function-declaration] Oh sorry, didn't see those ones. Will have patch up in a second.