From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 30DADA0C4E; Fri, 15 Oct 2021 15:09:45 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 02DD6411CB; Fri, 15 Oct 2021 15:09:45 +0200 (CEST) Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by mails.dpdk.org (Postfix) with ESMTP id 61459410F1 for ; Fri, 15 Oct 2021 15:09:43 +0200 (CEST) X-IronPort-AV: E=McAfee;i="6200,9189,10137"; a="251355784" X-IronPort-AV: E=Sophos;i="5.85,375,1624345200"; d="scan'208";a="251355784" Received: from orsmga006.jf.intel.com ([10.7.209.51]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Oct 2021 06:09:42 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.85,375,1624345200"; d="scan'208";a="442517020" Received: from fmsmsx602.amr.corp.intel.com ([10.18.126.82]) by orsmga006.jf.intel.com with ESMTP; 15 Oct 2021 06:09:42 -0700 Received: from fmsmsx610.amr.corp.intel.com (10.18.126.90) by fmsmsx602.amr.corp.intel.com (10.18.126.82) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2242.12; Fri, 15 Oct 2021 06:09:41 -0700 Received: from FMSEDG603.ED.cps.intel.com (10.1.192.133) by fmsmsx610.amr.corp.intel.com (10.18.126.90) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2242.12 via Frontend Transport; Fri, 15 Oct 2021 06:09:41 -0700 Received: from NAM04-DM6-obe.outbound.protection.outlook.com (104.47.73.48) by edgegateway.intel.com (192.55.55.68) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2242.12; Fri, 15 Oct 2021 06:09:41 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=IeMftXvOwN5v5LwUpCOuWVMgvNpUOomBUv465gLvn3bavEAzqdsAtPBKVsHO/gjHTdvYbnF7oHTYz+9vQ7C3y3FhqYXBHcCJ+4OxgkkMdd8uUp+D+siJijtuKwMlxUnQqOi1MNw2Qc1+1Es83FuxD8vICKYWCieHHDHVqpe/1oudmQYqnm1tlHrPBqCAZ0YvZmo09mdkuyK+FcEGKFG5nuJwRLGmCPt9AoAvvapBfqhCGrH+iaBEh9GjFRaifS5s1BNgTYJzWLf7n/fM2VGihIVOmizf1W+FWbe2Mg9Jpw4s23grWlCIny1nJZbCw+LrN2nCJft5UzeabdeFNx3s5A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=p+T25qzCvl8mWVZheD9Ask7GgSqBAqm5pFkghaAGLWs=; b=dL7FmTpecG+BZRm14dBzcWbbSW4GFPieQOC23l8DyAwWOGkgli9hQuUV9BS0d+271vaTOi40ma1Pls1JaYWuKnHn6q+K9bflB6ScAC3RPVNkT6rkjz52wqyUvJdlSTRdx7BCbn3csXzQAuQgJeNz56xkSVw7oqqkEkrWuuvXtOKUuLzS5HvtmBkQ17+wIhKPGBS0NpylIMpHZMLb7cxDVVyUBPJRN02TCXdnOUqF20oMBsH4LIcydJthlI/B0cDVMsU1JXQMM5KMAkvsIdNMvAcS11SZXNDD+dCE+R5i6KUblfZl3jnTnMtfP1d8QMLf/TndNNbj1nWAs9G2whk0lg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com; dkim=pass header.d=intel.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel.onmicrosoft.com; s=selector2-intel-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=p+T25qzCvl8mWVZheD9Ask7GgSqBAqm5pFkghaAGLWs=; b=Z3qR49UV5ZtRm04aadUB4+9eugIiWTEjWPaZc1Xzx6v3dCtVgjR3kG6HoPNE1eGN1rl4W2JdJTv1/C+PYWzm8eiiCrS84zGCSuYRjxzslfSJQbV1Ts0WE0P6/ve5RBUVrAGz0hXnBYxSWIl5ts2Z09/TE3SO7mO5rcSdtVviAgQ= Authentication-Results: intel.com; dkim=none (message not signed) header.d=none;intel.com; dmarc=none action=none header.from=intel.com; Received: from PH0PR11MB5013.namprd11.prod.outlook.com (2603:10b6:510:30::21) by PH0PR11MB5141.namprd11.prod.outlook.com (2603:10b6:510:3c::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4608.16; Fri, 15 Oct 2021 13:09:39 +0000 Received: from PH0PR11MB5013.namprd11.prod.outlook.com ([fe80::4c6a:b2b:c561:4c85]) by PH0PR11MB5013.namprd11.prod.outlook.com ([fe80::4c6a:b2b:c561:4c85%8]) with mapi id 15.20.4587.026; Fri, 15 Oct 2021 13:09:39 +0000 To: "Ananyev, Konstantin" , "dev@dpdk.org" CC: "Chilikin, Andrey" , "Wang, Yipeng1" , "Gobriel, Sameh" , "Richardson, Bruce" , "Mcnamara, John" References: <1630944239-363648-1-git-send-email-vladimir.medvedkin@intel.com> <1630944239-363648-2-git-send-email-vladimir.medvedkin@intel.com> From: "Medvedkin, Vladimir" Message-ID: <1e8a4e50-929f-c532-4dde-b717e1d2f57c@intel.com> Date: Fri, 15 Oct 2021 15:09:32 +0200 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Firefox/78.0 Thunderbird/78.14.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-ClientProxiedBy: DB6P191CA0009.EURP191.PROD.OUTLOOK.COM (2603:10a6:6:28::19) To PH0PR11MB5013.namprd11.prod.outlook.com (2603:10b6:510:30::21) MIME-Version: 1.0 Received: from [192.198.151.51] (192.198.151.51) by DB6P191CA0009.EURP191.PROD.OUTLOOK.COM (2603:10a6:6:28::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4566.16 via Frontend Transport; Fri, 15 Oct 2021 13:09:37 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 9cd505b1-28ba-4dbf-c29a-08d98fdd0b36 X-MS-TrafficTypeDiagnostic: PH0PR11MB5141: X-LD-Processed: 46c98d88-e344-4ed4-8496-4ed7712e255d,ExtAddr X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:8273; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: U0VgFv/o+Lf8kZ8D5ZEgEqFzFfqK5us0hfrx2YRrlbAOnk3cpercxX4CAzpotPWpEZmvT71rutq4JKUnjxqGFQBjGoyJ85w7wpaKfTTYINEnd1x6BBjaFdI2BsveN/zlOL0M8IhziGRVdZ2rlGJuzkxt/2asXPcf67LMeH9pY6j/hJD4u8aFUipoDCEmkCzAvLkeQaS3SS+tUDdY0E+3uz1Vr56YA8aFNvEOSDDvYM4vxa1KE5fwKaV7uAL+GdQoEjseBOZNO5Q2lA8FtuthIbI/SiCtp9oIyF9N2Jp+f1NSKBZQ3nfGx5FWXIzaQu3PfRDNSe4q7YcBblCKIYxeeAHv7dXOypz8b2PnpxpLkXmWbkcvdR+eA4sbR8F3pY/t9hbzTbf86xS6GVMdtChzfmHq94b8np51TcXpaRzI5w3JnKbd/dzMOVFPr1ZF6xm0S/5RSxmKBugSJ1XPCMi3MoawkHUrewWbZcclWAA0Kf6ZzdBkkpV8UnrpmVKOZTxy9uPlKT5jcTeSbvqFckVkb1wZNvkd/ppNN4kM2iEed0UxwotYKig7c2VPFz8W4rzWEzkZ6r5ECPWEs2PmGtvpZTEZXqGhP1yZrUfgxX3jRswk2+T57kjT68YMBiKR/6BLuEj4Tn2ZXSJ4q30TZXEDaefDrBclkq5jz0NlHxiZUzPz2ih/Ucjvl3/Belh8OnPTaQLsjFWeD9P85WiE51247nv+FzbQkCDS1ppq35o8nuuzpzPid0fn+Q2OhZoMKja96gNhdBvUuTda0y++19Jjsg== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:PH0PR11MB5013.namprd11.prod.outlook.com; PTR:; CAT:NONE; SFS:(366004)(66556008)(53546011)(316002)(6666004)(66946007)(8676002)(66476007)(83380400001)(38100700002)(54906003)(82960400001)(5660300002)(16576012)(36756003)(110136005)(31686004)(186003)(6486002)(2616005)(31696002)(2906002)(956004)(8936002)(508600001)(4326008)(6706004)(26005)(107886003)(86362001)(3940600001)(45980500001)(43740500002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?aFFldlhpcytjS0NGSnNwdU14RlBya3cwRUVHUHF0Sm9ZTzVLUFJwWTkzV1B6?= =?utf-8?B?S21ITm9qR0FzV0pHK3pmSU8yd1hlenljcElicFF2YWVpeDJMZjB2SlJCRytM?= =?utf-8?B?eEI2cmV6b3k5OXkxSzM3UjhNQUxYaHVMWHd4TXptU0Z3WHBEUnlCMVBUUitM?= =?utf-8?B?N0dMeVcxSkJkSWt3dmlNWDFyOGUwSGxWZFZReXl1WEFNRXJIOEdFMlM1Qmli?= =?utf-8?B?S3ZCZVVaTWwvMFZ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?utf-8?B?djl4aHVvYVFiMkdkVlhCV0g2b2E3STlLWXJoU2tQeElNYlNJUEs1R09XWS9G?= =?utf-8?B?R0tmUVRaQzM1d3dDMnZEMlowRmNBUzdhY1FHQTRUNmdRWnQyYzRHWXg1cnhq?= =?utf-8?B?aWFDR2dCSkZxa2RwTVhvdkpGWWQvSm9aT0YzTWlvL0dOa09sekMxZU1aZnpE?= =?utf-8?B?VHlpZEpZR0JtSndXSmYrOWxGL3ZXVmgwaG5UZG41c0RSb1FKSFI2ZkloTHpS?= =?utf-8?B?cERxYnV6aGlZODk4Qk1VbWxaZDdaREh1ajVMWWxheDBoY1E4WnBJN2tLYmcv?= =?utf-8?B?YUx0QlhVTE5hM212ZjNxdytndkZFV3IvSkFxWDVERlc5d21YOUpjMjI4cUVV?= =?utf-8?B?SEt6THNQT3RDcWNGWGZSMXV0S00weU15NVlnNVdCdWV6UTZQVmlVdDJNUFdX?= =?utf-8?B?M1dMaENhTTRRWDIvemduaWgrZ2pLU092Z0dlaFJrYjZtSzNEVWpqdlRaOEVF?= =?utf-8?B?ZUNqRGlzRzB2ZStTUVhtVEdwVUhDdmE4MHhSZ1hVZGdoOE1oQXJvZWpzZUF2?= =?utf-8?B?Q3lnV0gxbDZNTWpVSWlXVm4vUEFXQ1Vac2dKS2FXRjhPekdsdnJTOG96RnRR?= =?utf-8?Q?el8kMFE16udQsAUb+yodSJvSaDH8RE77T+SG/4A?= X-MS-Exchange-CrossTenant-Network-Message-Id: 9cd505b1-28ba-4dbf-c29a-08d98fdd0b36 X-MS-Exchange-CrossTenant-AuthSource: PH0PR11MB5013.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Oct 2021 13:09:38.9682 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 46c98d88-e344-4ed4-8496-4ed7712e255d X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: lICvtxqxXroDkr6eXA7YPL0/YNSkpk3+Td/nmJz/N/lk5HDFcVEIhJx5mbP3V4UYpyO6RFwfue8vC/68Pfb3/n8g4CBznpGBkDY2Xj+16kM= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR11MB5141 X-OriginatorOrg: intel.com Subject: Re: [dpdk-dev] [PATCH 1/5] hash: add new toeplitz hash implementation X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 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" On 15/10/2021 12:55, Ananyev, Konstantin wrote: > >>>> +/** >>>> + * Calculate Toeplitz hash. >>>> + * >>>> + * @warning >>>> + * @b EXPERIMENTAL: this API may change without prior notice. >>>> + * >>>> + * @param m >>>> + * Pointer to the matrices generated from the corresponding >>>> + * RSS hash key using rte_thash_complete_matrix(). >>>> + * @param tuple >>>> + * Pointer to the data to be hashed. Data must be in network byte order. >>>> + * @param len >>>> + * Length of the data to be hashed. >>>> + * @return >>>> + * Calculated Toeplitz hash value. >>>> + */ >>>> +__rte_experimental >>>> +static inline uint32_t >>>> +rte_thash_gfni(uint64_t *m, uint8_t *tuple, int len) >>>> +{ >>>> + uint32_t val, val_zero; >>>> + >>>> + __m512i xor_acc = __rte_thash_gfni(m, tuple, NULL, len); >>>> + __rte_thash_xor_reduce(xor_acc, &val, &val_zero); >>>> + >>>> + return val; >>>> +} >>>> + >>>> +/** >>>> + * Calculate Toeplitz hash for two independent data buffers. >>>> + * >>>> + * @warning >>>> + * @b EXPERIMENTAL: this API may change without prior notice. >>>> + * >>>> + * @param m >>>> + * Pointer to the matrices generated from the corresponding >>>> + * RSS hash key using rte_thash_complete_matrix(). >>>> + * @param tuple_1 >>>> + * Pointer to the data to be hashed. Data must be in network byte order. >>>> + * @param tuple_2 >>>> + * Pointer to the data to be hashed. Data must be in network byte order. >>>> + * @param len >>>> + * Length of the largest data buffer to be hashed. >>>> + * @param val_1 >>>> + * Pointer to uint32_t where to put calculated Toeplitz hash value for >>>> + * the first tuple. >>>> + * @param val_2 >>>> + * Pointer to uint32_t where to put calculated Toeplitz hash value for >>>> + * the second tuple. >>>> + */ >>>> +__rte_experimental >>>> +static inline void >>>> +rte_thash_gfni_x2(uint64_t *mtrx, uint8_t *tuple_1, uint8_t *tuple_2, int len, >>>> + uint32_t *val_1, uint32_t *val_2) >>> >>> Why just two? >>> Why not uint8_t *tuple[] >>> ? >>> >> >> x2 version was added because there was unused space inside the ZMM which >> holds input key (input tuple) bytes for a second input key, so it helps >> to improve performance in some cases. >> Bulk version wasn't added because for the vast majority of cases it will >> be used with a single input key. >> Hiding this function inside .c will greatly affect performance, because >> it takes just a few cycles to calculate the hash for the most popular >> key sizes. > > Ok, but it still unclear to me why for 2 only? > What stops you from doing: > static inline void > rte_thash_gfni_bulk(const uint64_t *mtrx, uint32_t len, uint8_t *tuple[], uint32_t val[], uint32_t num) > { > for (i = 0; i != (num & ~1); i += 2) { > xor_acc = __rte_thash_gfni(mtrx, tuple[i], tuple[i+ 1], len); > __rte_thash_xor_reduce(xor_acc, val + i, val + i + 1); > } > If (num & 1) { > xor_acc = __rte_thash_gfni(mtrx, tuple[i], NULL, len); > __rte_thash_xor_reduce(xor_acc, val + i, &val_zero); > } > } > ? > I think you're right. Given that the mathematical properties of this hash function are clear and it is very fast, it can be used with rte_hash, so bulk version will be useful. I'll replace in v3 the _x2() version with _bulk() as you suggested. -- Regards, Vladimir