Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rrPw2-000U12-Kp for pgsql-hackers@arkaria.postgresql.org; Mon, 01 Apr 2024 22:15:23 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1rrPw1-002LCG-4f for pgsql-hackers@arkaria.postgresql.org; Mon, 01 Apr 2024 22:15:21 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rrPw0-002LC8-RZ for pgsql-hackers@lists.postgresql.org; Mon, 01 Apr 2024 22:15:21 +0000 Received: from mail-vs1-xe2f.google.com ([2607:f8b0:4864:20::e2f]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1rrPvw-00037a-MW for pgsql-hackers@lists.postgresql.org; Mon, 01 Apr 2024 22:15:19 +0000 Received: by mail-vs1-xe2f.google.com with SMTP id ada2fe7eead31-47866551165so648441137.1 for ; Mon, 01 Apr 2024 15:15:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1712009715; x=1712614515; darn=lists.postgresql.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=YOg8lfibRiM/yPwoARY8E3HtxchZVtZ6iARtqJAL51k=; b=Bf7UdTyk2VT5Gu0nqTxB4SpuB/5l9LoUuEb+MmzkCunUnrwu8+YnZs21N/mR41RixB Nb7GHFnIY1u7EcYnPELU2hzsaxrm1HRRVRnyZtW9GfGHjiiCEKtuScJdCZspqZfhxuBp /757kIvBkFHCAsaJCZOAmaF3J3dzNIPQ3WORWxIgs+rtgfjU0U+r7MesOIykWYf4l926 akRN2THK1XcxSP477mVbH6mWyaF71uihGhexx9EXx6WS80VZvPhPDeM+jrghapNimOZ1 HRtWDCWoI0IJJ1oUDzvyLPXp5+s0xwVVTwfwOCthjvqRVCU3tWgfB1iHKkpI0cGU+ZhG F+9Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712009715; x=1712614515; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=YOg8lfibRiM/yPwoARY8E3HtxchZVtZ6iARtqJAL51k=; b=OboMyKkUswsGF+gpCXXt/ZFubl9bVotZbpsAnbW7Ief+KWCjjnl4zOC6Gk4/Z3+dE9 0OQWSHp8PyOUHbSUAu7mlXsnY+UE3PBeXXkKmp6OGrl0MXfx/i6iO4PKU9WZ9Ypn/2Gi t5M5WRNlbbXbpxhozqVS5K+kLzYKQgms7tVDZeX2BwzJf1yfcskCb0NrlxDLk2VN5NbC MYzauNaYOlxKLE9JykwgWjf4TBPLXm6e7+3cod+4Mi+AYzfs2BvGSiW6b3wbFFVaQXyb gzuwEqXmIM9GkZ8NS3s5a4ibQSTYFwqeIuFN5gQTJIdEu1Q34GhJoLRDpLXT4caUHo8T gPvg== X-Forwarded-Encrypted: i=1; AJvYcCXzvTkfGcC95LdM3M8y/VhyHgPz1l+g6Vv/bkSQBzvqCnlDe3ME/DJydI+e2kimNjKH7HzEt9OhWHsh0o1cvgJY6n8kqvTJg4SUPP3AtR7HtKg1 X-Gm-Message-State: AOJu0Yz64W7nLRJexdjvil5J7wI4TQVMcpeP3oM0th07uLGMqflVFvVh cHAaO+k1LAe4j2DMvlJwiXyTMDoprfEVbInf+wuqH1EqsiG7H3eq X-Google-Smtp-Source: AGHT+IHjoDVHIZ4vfyt89+XeSTQCjU3gJVOO45VPTdkQHajGejSil6leOkf5BfDLj1fTbWe2dFUAJg== X-Received: by 2002:a67:fb1a:0:b0:476:d5c5:432c with SMTP id d26-20020a67fb1a000000b00476d5c5432cmr7559112vsr.5.1712009714964; Mon, 01 Apr 2024 15:15:14 -0700 (PDT) Received: from nathanxps13 (162-195-168-172.lightspeed.stlsmo.sbcglobal.net. [162.195.168.172]) by smtp.gmail.com with ESMTPSA id gc15-20020a056214230f00b00690fc99a836sm4839846qvb.105.2024.04.01.15.15.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Apr 2024 15:15:14 -0700 (PDT) Date: Mon, 1 Apr 2024 17:15:12 -0500 From: Nathan Bossart To: Ants Aasma Cc: Alvaro Herrera , "Amonson, Paul D" , Tom Lane , David Rowley , Andres Freund , "Shankaran, Akash" , Noah Misch , Matthias van de Meent , "pgsql-hackers@lists.postgresql.org" Subject: Re: Popcount optimization using AVX512 Message-ID: <20240401221512.GA2511488@nathanxps13> References: <20240401011708.GA2128739@nathanxps13> <202404011106.y4fci35kzdqt@alvherre.pgsql> <20240401155338.GA2296072@nathanxps13> <20240401213140.GA2362108@nathanxps13> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Tue, Apr 02, 2024 at 01:09:57AM +0300, Ants Aasma wrote: > On Tue, 2 Apr 2024 at 00:31, Nathan Bossart wrote: >> On Tue, Apr 02, 2024 at 12:11:59AM +0300, Ants Aasma wrote: >> > What about using the masking capabilities of AVX-512 to handle the >> > tail in the same code path? Masked out portions of a load instruction >> > will not generate an exception. To allow byte level granularity >> > masking, -mavx512bw is needed. Based on wikipedia this will only >> > disable this fast path on Knights Mill (Xeon Phi), in all other cases >> > VPOPCNTQ implies availability of BW. >> >> Sounds promising. IMHO we should really be sure that these kinds of loads >> won't generate segfaults and the like due to the masked-out portions. I >> searched around a little bit but haven't found anything that seemed >> definitive. > > Interestingly the Intel software developer manual is not exactly > crystal clear on how memory faults with masks work, but volume 2A > chapter 2.8 [1] does specify that MOVDQU8 is of exception class E4.nb > that supports memory fault suppression on page fault. Perhaps Paul or Akash could chime in here... -- Nathan Bossart Amazon Web Services: https://aws.amazon.com