Less compiler errors in pg_crc32c_sse42_choose.c

From: Nat! <nat(at)mulle-kybernetik(dot)com>
To: pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Less compiler errors in pg_crc32c_sse42_choose.c
Date: 2021-06-15 13:04:11
Message-ID: 9EC6E8BE-EC15-4778-8FED-95077167C0AD@mulle-kybernetik.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

<html><head></head><body dir="auto" style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;"><div dir="auto" style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;"><meta http-equiv="Content-Type" content="text/html; charset=us-ascii"><div style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><div style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">I am just quoting the whole file here for simplicity, as its small</span></div><div style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""><br class=""></span></div><div style="margin: 0px; font-stretch: normal; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures; font-size: 11px;" class=""><font face="Menlo" class=""><a href="https://git.postgresql.org/gitweb/?p=postgresql.git;a=blob;f=src/port/pg_crc32c_sse42_choose.c;h=0608e02011f7f5d8dbba7673a5ab4ba071d017a0;hb=e4f9737fac77a5cb03a84d1f4038d300ffd28afd" class="">https://git.postgresql.org/gitweb/?p=postgresql.git;a=blob;f=src/port/pg_crc32c_sse42_choose.c;h=0608e02011f7f5d8dbba7673a5ab4ba071d017a0;hb=e4f9737fac77a5cb03a84d1f4038d300ffd28afd</a>.</font></span></div><div style="margin: 0px; font-stretch: normal; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures; font-size: 11px;" class=""><font face="Menlo" class=""><br class=""></font></span></div><div style="margin: 0px; font-stretch: normal; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures; font-size: 11px;" class=""><font face="Menlo" class="">In line #43 the compiler errors out, if there is no cpuid.h or intrin.h available. As the code is supposed to&nbsp;</font></span></div><div style="margin: 0px; font-stretch: normal; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures; font-size: 11px;" class=""><font face="Menlo" class="">fallback on a CRC software implementation, if SSE isn't available, returning false here instead, would be better</font></span><span style="font-family: Menlo; font-size: 11px;" class="">.&nbsp;</span></div><div style="margin: 0px; font-stretch: normal; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures; font-size: 11px;" class=""><font face="Menlo" class=""><br class=""></font></span></div><div style="margin: 0px; font-stretch: normal; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures; font-size: 11px;" class=""><font face="Menlo" class=""><br class=""></font></span></div><div style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">Ciao</span></div><div style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">&nbsp; &nbsp;Nat!</span></div><div style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""><br class=""></span></div><div style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">```</span></div><div style="margin: 0px; font-stretch: normal; line-height: normal;" class=""><div style="margin: 0px; font-stretch: normal; line-height: normal;" class=""><font face="Menlo" class=""><span style="font-size: 11px;" class="">&nbsp; &nbsp;1 /*-------------------------------------------------------------------------</span></font></div><div style="margin: 0px; font-stretch: normal; line-height: normal;" class=""><font face="Menlo" class=""><span style="font-size: 11px;" class="">&nbsp; &nbsp;2 &nbsp;*</span></font></div><div style="margin: 0px; font-stretch: normal; line-height: normal;" class=""><font face="Menlo" class=""><span style="font-size: 11px;" class="">&nbsp; &nbsp;3 &nbsp;* pg_crc32c_sse42_choose.c</span></font></div><div style="margin: 0px; font-stretch: normal; line-height: normal;" class=""><font face="Menlo" class=""><span style="font-size: 11px;" class="">&nbsp; &nbsp;4 &nbsp;* &nbsp; &nbsp;Choose between Intel SSE 4.2 and software CRC-32C implementation.</span></font></div><div style="margin: 0px; font-stretch: normal; line-height: normal;" class=""><font face="Menlo" class=""><span style="font-size: 11px;" class="">&nbsp; &nbsp;5 &nbsp;*</span></font></div><div style="margin: 0px; font-stretch: normal; line-height: normal;" class=""><font face="Menlo" class=""><span style="font-size: 11px;" class="">&nbsp; &nbsp;6 &nbsp;* On first call, checks if the CPU we're running on supports Intel SSE</span></font></div><div style="margin: 0px; font-stretch: normal; line-height: normal;" class=""><font face="Menlo" class=""><span style="font-size: 11px;" class="">&nbsp; &nbsp;7 &nbsp;* 4.2. If it does, use the special SSE instructions for CRC-32C</span></font></div><div style="margin: 0px; font-stretch: normal; line-height: normal;" class=""><font face="Menlo" class=""><span style="font-size: 11px;" class="">&nbsp; &nbsp;8 &nbsp;* computation. Otherwise, fall back to the pure software implementation</span></font></div><div style="margin: 0px; font-stretch: normal; line-height: normal;" class=""><font face="Menlo" class=""><span style="font-size: 11px;" class="">&nbsp; &nbsp;9 &nbsp;* (slicing-by-8).</span></font></div><div style="margin: 0px; font-stretch: normal; line-height: normal;" class=""><font face="Menlo" class=""><span style="font-size: 11px;" class="">&nbsp; 10 &nbsp;*</span></font></div><div style="margin: 0px; font-stretch: normal; line-height: normal;" class=""><font face="Menlo" class=""><span style="font-size: 11px;" class="">&nbsp; 11 &nbsp;* Portions Copyright (c) 1996-2021, PostgreSQL Global Development Group</span></font></div><div style="margin: 0px; font-stretch: normal; line-height: normal;" class=""><font face="Menlo" class=""><span style="font-size: 11px;" class="">&nbsp; 12 &nbsp;* Portions Copyright (c) 1994, Regents of the University of California</span></font></div><div style="margin: 0px; font-stretch: normal; line-height: normal;" class=""><font face="Menlo" class=""><span style="font-size: 11px;" class="">&nbsp; 13 &nbsp;*</span></font></div><div style="margin: 0px; font-stretch: normal; line-height: normal;" class=""><font face="Menlo" class=""><span style="font-size: 11px;" class="">&nbsp; 14 &nbsp;*</span></font></div><div style="margin: 0px; font-stretch: normal; line-height: normal;" class=""><font face="Menlo" class=""><span style="font-size: 11px;" class="">&nbsp; 15 &nbsp;* IDENTIFICATION</span></font></div><div style="margin: 0px; font-stretch: normal; line-height: normal;" class=""><font face="Menlo" class=""><span style="font-size: 11px;" class="">&nbsp; 16 &nbsp;* &nbsp; &nbsp;src/port/pg_crc32c_sse42_choose.c</span></font></div><div style="margin: 0px; font-stretch: normal; line-height: normal;" class=""><font face="Menlo" class=""><span style="font-size: 11px;" class="">&nbsp; 17 &nbsp;*</span></font></div><div style="margin: 0px; font-stretch: normal; line-height: normal;" class=""><font face="Menlo" class=""><span style="font-size: 11px;" class="">&nbsp; 18 &nbsp;*-------------------------------------------------------------------------</span></font></div><div style="margin: 0px; font-stretch: normal; line-height: normal;" class=""><font face="Menlo" class=""><span style="font-size: 11px;" class="">&nbsp; 19 &nbsp;*/</span></font></div><div style="margin: 0px; font-stretch: normal; line-height: normal;" class=""><font face="Menlo" class=""><span style="font-size: 11px;" class="">&nbsp; 20&nbsp;</span></font></div><div style="margin: 0px; font-stretch: normal; line-height: normal;" class=""><font face="Menlo" class=""><span style="font-size: 11px;" class="">&nbsp; 21 #include "c.h"</span></font></div><div style="margin: 0px; font-stretch: normal; line-height: normal;" class=""><font face="Menlo" class=""><span style="font-size: 11px;" class="">&nbsp; 22&nbsp;</span></font></div><div style="margin: 0px; font-stretch: normal; line-height: normal;" class=""><font face="Menlo" class=""><span style="font-size: 11px;" class="">&nbsp; 23 #ifdef HAVE__GET_CPUID</span></font></div><div style="margin: 0px; font-stretch: normal; line-height: normal;" class=""><font face="Menlo" class=""><span style="font-size: 11px;" class="">&nbsp; 24 #include &lt;cpuid.h&gt;</span></font></div><div style="margin: 0px; font-stretch: normal; line-height: normal;" class=""><font face="Menlo" class=""><span style="font-size: 11px;" class="">&nbsp; 25 #endif</span></font></div><div style="margin: 0px; font-stretch: normal; line-height: normal;" class=""><font face="Menlo" class=""><span style="font-size: 11px;" class="">&nbsp; 26&nbsp;</span></font></div><div style="margin: 0px; font-stretch: normal; line-height: normal;" class=""><font face="Menlo" class=""><span style="font-size: 11px;" class="">&nbsp; 27 #ifdef HAVE__CPUID</span></font></div><div style="margin: 0px; font-stretch: normal; line-height: normal;" class=""><font face="Menlo" class=""><span style="font-size: 11px;" class="">&nbsp; 28 #include &lt;intrin.h&gt;</span></font></div><div style="margin: 0px; font-stretch: normal; line-height: normal;" class=""><font face="Menlo" class=""><span style="font-size: 11px;" class="">&nbsp; 29 #endif</span></font></div><div style="margin: 0px; font-stretch: normal; line-height: normal;" class=""><font face="Menlo" class=""><span style="font-size: 11px;" class="">&nbsp; 30&nbsp;</span></font></div><div style="margin: 0px; font-stretch: normal; line-height: normal;" class=""><font face="Menlo" class=""><span style="font-size: 11px;" class="">&nbsp; 31 #include "port/pg_crc32c.h"</span></font></div><div style="margin: 0px; font-stretch: normal; line-height: normal;" class=""><font face="Menlo" class=""><span style="font-size: 11px;" class="">&nbsp; 32&nbsp;</span></font></div><div style="margin: 0px; font-stretch: normal; line-height: normal;" class=""><font face="Menlo" class=""><span style="font-size: 11px;" class="">&nbsp; 33 static bool</span></font></div><div style="margin: 0px; font-stretch: normal; line-height: normal;" class=""><font face="Menlo" class=""><span style="font-size: 11px;" class="">&nbsp; 34 pg_crc32c_sse42_available(void)</span></font></div><div style="margin: 0px; font-stretch: normal; line-height: normal;" class=""><font face="Menlo" class=""><span style="font-size: 11px;" class="">&nbsp; 35 {</span></font></div><div style="margin: 0px; font-stretch: normal; line-height: normal;" class=""><font face="Menlo" class=""><span style="font-size: 11px;" class="">&nbsp; 36 &nbsp; &nbsp; unsigned int exx[4] = {0, 0, 0, 0};</span></font></div><div style="margin: 0px; font-stretch: normal; line-height: normal;" class=""><font face="Menlo" class=""><span style="font-size: 11px;" class="">&nbsp; 37&nbsp;</span></font></div><div style="margin: 0px; font-stretch: normal; line-height: normal;" class=""><font face="Menlo" class=""><span style="font-size: 11px;" class="">&nbsp; 38 #if defined(HAVE__GET_CPUID)</span></font></div><div style="margin: 0px; font-stretch: normal; line-height: normal;" class=""><font face="Menlo" class=""><span style="font-size: 11px;" class="">&nbsp; 39 &nbsp; &nbsp; __get_cpuid(1, &amp;exx[0], &amp;exx[1], &amp;exx[2], &amp;exx[3]);</span></font></div><div style="margin: 0px; font-stretch: normal; line-height: normal;" class=""><font face="Menlo" class=""><span style="font-size: 11px;" class="">&nbsp; 40 #elif defined(HAVE__CPUID)</span></font></div><div style="margin: 0px; font-stretch: normal; line-height: normal;" class=""><font face="Menlo" class=""><span style="font-size: 11px;" class="">&nbsp; 41 &nbsp; &nbsp; __cpuid(exx, 1);</span></font></div><div style="margin: 0px; font-stretch: normal; line-height: normal;" class=""><font face="Menlo" class=""><span style="font-size: 11px;" class="">&nbsp; 42 #else</span></font></div><div style="margin: 0px; font-stretch: normal; line-height: normal;" class=""><font face="Menlo" class=""><span style="font-size: 11px;" class="">&nbsp; 43 #error cpuid instruction not available</span></font></div><div style="margin: 0px; font-stretch: normal; line-height: normal;" class=""><font face="Menlo" class=""><span style="font-size: 11px;" class="">&nbsp; 44 #endif</span></font></div><div style="margin: 0px; font-stretch: normal; line-height: normal;" class=""><font face="Menlo" class=""><span style="font-size: 11px;" class="">&nbsp; 45&nbsp;</span></font></div><div style="margin: 0px; font-stretch: normal; line-height: normal;" class=""><font face="Menlo" class=""><span style="font-size: 11px;" class="">&nbsp; 46 &nbsp; &nbsp; return (exx[2] &amp; (1 &lt;&lt; 20)) != 0; &nbsp; /* SSE 4.2 */</span></font></div><div style="margin: 0px; font-stretch: normal; line-height: normal;" class=""><font face="Menlo" class=""><span style="font-size: 11px;" class="">&nbsp; 47 }</span></font></div><div style="margin: 0px; font-stretch: normal; line-height: normal;" class=""><font face="Menlo" class=""><span style="font-size: 11px;" class="">&nbsp; 48&nbsp;</span></font></div><div style="margin: 0px; font-stretch: normal; line-height: normal;" class=""><font face="Menlo" class=""><span style="font-size: 11px;" class="">&nbsp; 49 /*</span></font></div><div style="margin: 0px; font-stretch: normal; line-height: normal;" class=""><font face="Menlo" class=""><span style="font-size: 11px;" class="">&nbsp; 50 &nbsp;* This gets called on the first call. It replaces the function pointer</span></font></div><div style="margin: 0px; font-stretch: normal; line-height: normal;" class=""><font face="Menlo" class=""><span style="font-size: 11px;" class="">&nbsp; 51 &nbsp;* so that subsequent calls are routed directly to the chosen implementation.</span></font></div><div style="margin: 0px; font-stretch: normal; line-height: normal;" class=""><font face="Menlo" class=""><span style="font-size: 11px;" class="">&nbsp; 52 &nbsp;*/</span></font></div><div style="margin: 0px; font-stretch: normal; line-height: normal;" class=""><font face="Menlo" class=""><span style="font-size: 11px;" class="">&nbsp; 53 static pg_crc32c</span></font></div><div style="margin: 0px; font-stretch: normal; line-height: normal;" class=""><font face="Menlo" class=""><span style="font-size: 11px;" class="">&nbsp; 54 pg_comp_crc32c_choose(pg_crc32c crc, const void *data, size_t len)</span></font></div><div style="margin: 0px; font-stretch: normal; line-height: normal;" class=""><font face="Menlo" class=""><span style="font-size: 11px;" class="">&nbsp; 55 {</span></font></div><div style="margin: 0px; font-stretch: normal; line-height: normal;" class=""><font face="Menlo" class=""><span style="font-size: 11px;" class="">&nbsp; 56 &nbsp; &nbsp; if (pg_crc32c_sse42_available())</span></font></div><div style="margin: 0px; font-stretch: normal; line-height: normal;" class=""><font face="Menlo" class=""><span style="font-size: 11px;" class="">&nbsp; 57 &nbsp; &nbsp; &nbsp; &nbsp; pg_comp_crc32c = pg_comp_crc32c_sse42;</span></font></div><div style="margin: 0px; font-stretch: normal; line-height: normal;" class=""><font face="Menlo" class=""><span style="font-size: 11px;" class="">&nbsp; 58 &nbsp; &nbsp; else</span></font></div><div style="margin: 0px; font-stretch: normal; line-height: normal;" class=""><font face="Menlo" class=""><span style="font-size: 11px;" class="">&nbsp; 59 &nbsp; &nbsp; &nbsp; &nbsp; pg_comp_crc32c = pg_comp_crc32c_sb8;</span></font></div><div style="margin: 0px; font-stretch: normal; line-height: normal;" class=""><font face="Menlo" class=""><span style="font-size: 11px;" class="">&nbsp; 60&nbsp;</span></font></div><div style="margin: 0px; font-stretch: normal; line-height: normal;" class=""><font face="Menlo" class=""><span style="font-size: 11px;" class="">&nbsp; 61 &nbsp; &nbsp; return pg_comp_crc32c(crc, data, len);</span></font></div><div style="margin: 0px; font-stretch: normal; line-height: normal;" class=""><font face="Menlo" class=""><span style="font-size: 11px;" class="">&nbsp; 62 }</span></font></div><div style="margin: 0px; font-stretch: normal; line-height: normal;" class=""><font face="Menlo" class=""><span style="font-size: 11px;" class="">&nbsp; 63&nbsp;</span></font></div><div style="margin: 0px; font-stretch: normal; line-height: normal;" class=""><font face="Menlo" class=""><span style="font-size: 11px;" class="">&nbsp; 64 pg_crc32c &nbsp; (*pg_comp_crc32c) (pg_crc32c crc, const void *data, size_t len) = pg_comp_crc32c_choose;</span></font></div></div><div style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">```</span></div><div style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""><br class=""></span></div><div class=""><span style="font-variant-ligatures: no-common-ligatures" class=""><br class=""></span></div></div></div></body></html>

Attachment Content-Type Size
unknown_filename text/html 17.2 KB

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Alexander Korotkov 2021-06-15 13:10:21 Re: unnesting multirange data types
Previous Message Yugo NAGATA 2021-06-15 12:53:06 Re: Error on pgbench logs