You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@arrow.apache.org by "Arkadiy Vertleyb (BLOOMBERG/ 120 PARK)" <av...@bloomberg.net> on 2022/06/07 19:34:27 UTC

Cpp Win32/MSVC build

Hi all,

I just created ARROW-16778 to address C++ build issues under MSVC/Win32.  The following patch can fix the issue:

index 8583e10b2..496bbb78b 100644
--- a/cpp/src/arrow/util/bit_util.h
+++ b/cpp/src/arrow/util/bit_util.h
@@ -67,7 +67,14 @@ static constexpr uint8_t kBytePopcount[] = {
     5, 4, 5, 5, 6, 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7, 3, 4, 4, 5, 4, 5, 5, 6,
     4, 5, 5, 6, 5, 6, 6, 7, 4, 5, 5, 6, 5, 6, 6, 7, 5, 6, 6, 7, 6, 7, 7, 8};

+#if defined(_MSC_VER) && !defined(_M_AMD64) && !defined(_M_X64)
+static inline uint64_t PopCount(uint64_t bitmap) {
+  uint32_t* p = reinterpret_cast<uint32_t*>(&bitmap);
+  return ARROW_POPCOUNT32(*p) + ARROW_POPCOUNT32(*(p + 1));
+}
+#else
 static inline uint64_t PopCount(uint64_t bitmap) { return ARROW_POPCOUNT64(bitmap); }
+#endif
 static inline uint32_t PopCount(uint32_t bitmap) { return ARROW_POPCOUNT32(bitmap); }

 //
@@ -199,7 +206,7 @@ static inline int CountLeadingZeros(uint64_t value) {
 #if defined(__clang__) || defined(__GNUC__)
   if (value == 0) return 64;
   return static_cast<int>(__builtin_clzll(value));
-#elif defined(_MSC_VER)
+#elif defined(_MSC_VER) && (defined(_M_AMD64) || defined(_M_X64))
   unsigned long index;                     // NOLINT
   if (_BitScanReverse64(&index, value)) {  // NOLINT
     return 63 - static_cast<int>(index);
@@ -220,7 +227,7 @@ static inline int CountTrailingZeros(uint32_t value) {
 #if defined(__clang__) || defined(__GNUC__)
   if (value == 0) return 32;
   return static_cast<int>(__builtin_ctzl(value));
-#elif defined(_MSC_VER)
+#elif defined(_MSC_VER) && (defined(_M_AMD64) || defined(_M_X64))
   unsigned long index;  // NOLINT
   if (_BitScanForward(&index, value)) {
     return static_cast<int>(index);
@@ -245,7 +252,7 @@ static inline int CountTrailingZeros(uint64_t value) {
 #if defined(__clang__) || defined(__GNUC__)
   if (value == 0) return 64;
   return static_cast<int>(__builtin_ctzll(value));
-#elif defined(_MSC_VER)
+#elif defined(_MSC_VER) && (defined(_M_AMD64) || defined(_M_X64))
   unsigned long index;  // NOLINT
   if (_BitScanForward64(&index, value)) {
     return static_cast<int>(index);

Please let me know how do I submit this issue for approval.

Thanks,
Arkadiy

Re: Cpp Win32/MSVC build

Posted by James Duong <ja...@bitquilltech.com.INVALID>.
Hi Arkadiy Vertleyb,

I saw your PR (https://github.com/apache/arrow/pull/13376) had closed a
couple of weeks ago and there haven't been comments in JIRA for awhile as
well. Were you still planning to work on this?
I'd be interested in helping to finish this off in either case.

On Tue, Jun 7, 2022 at 5:13 PM Sutou Kouhei <ko...@clear-code.com> wrote:

> Hi,
>
> Could you open a pull request on
> https://github.com/apache/arrow to review the patch?
>
> See also:
>
>   *
> https://arrow.apache.org/docs/developers/guide/step_by_step/pr_lifecycle.html#create-pr
>   *
> https://arrow.apache.org/docs/developers/overview.html#pull-request-and-review
>
>
> Thanks,
> --
> kou
>
> In <62...@msllnjpmsgsv06>
>   "Cpp Win32/MSVC build" on Tue, 7 Jun 2022 19:34:27 -0000,
>   "Arkadiy Vertleyb (BLOOMBERG/ 120 PARK)" <av...@bloomberg.net>
> wrote:
>
> > Hi all,
> >
> > I just created ARROW-16778 to address C++ build issues under
> MSVC/Win32.  The following patch can fix the issue:
> >
> > index 8583e10b2..496bbb78b 100644
> > --- a/cpp/src/arrow/util/bit_util.h
> > +++ b/cpp/src/arrow/util/bit_util.h
> > @@ -67,7 +67,14 @@ static constexpr uint8_t kBytePopcount[] = {
> >      5, 4, 5, 5, 6, 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7, 3,
> 4, 4, 5, 4, 5, 5, 6,
> >      4, 5, 5, 6, 5, 6, 6, 7, 4, 5, 5, 6, 5, 6, 6, 7, 5, 6, 6, 7, 6, 7,
> 7, 8};
> >
> > +#if defined(_MSC_VER) && !defined(_M_AMD64) && !defined(_M_X64)
> > +static inline uint64_t PopCount(uint64_t bitmap) {
> > +  uint32_t* p = reinterpret_cast<uint32_t*>(&bitmap);
> > +  return ARROW_POPCOUNT32(*p) + ARROW_POPCOUNT32(*(p + 1));
> > +}
> > +#else
> >  static inline uint64_t PopCount(uint64_t bitmap) { return
> ARROW_POPCOUNT64(bitmap); }
> > +#endif
> >  static inline uint32_t PopCount(uint32_t bitmap) { return
> ARROW_POPCOUNT32(bitmap); }
> >
> >  //
> > @@ -199,7 +206,7 @@ static inline int CountLeadingZeros(uint64_t value) {
> >  #if defined(__clang__) || defined(__GNUC__)
> >    if (value == 0) return 64;
> >    return static_cast<int>(__builtin_clzll(value));
> > -#elif defined(_MSC_VER)
> > +#elif defined(_MSC_VER) && (defined(_M_AMD64) || defined(_M_X64))
> >    unsigned long index;                     // NOLINT
> >    if (_BitScanReverse64(&index, value)) {  // NOLINT
> >      return 63 - static_cast<int>(index);
> > @@ -220,7 +227,7 @@ static inline int CountTrailingZeros(uint32_t value)
> {
> >  #if defined(__clang__) || defined(__GNUC__)
> >    if (value == 0) return 32;
> >    return static_cast<int>(__builtin_ctzl(value));
> > -#elif defined(_MSC_VER)
> > +#elif defined(_MSC_VER) && (defined(_M_AMD64) || defined(_M_X64))
> >    unsigned long index;  // NOLINT
> >    if (_BitScanForward(&index, value)) {
> >      return static_cast<int>(index);
> > @@ -245,7 +252,7 @@ static inline int CountTrailingZeros(uint64_t value)
> {
> >  #if defined(__clang__) || defined(__GNUC__)
> >    if (value == 0) return 64;
> >    return static_cast<int>(__builtin_ctzll(value));
> > -#elif defined(_MSC_VER)
> > +#elif defined(_MSC_VER) && (defined(_M_AMD64) || defined(_M_X64))
> >    unsigned long index;  // NOLINT
> >    if (_BitScanForward64(&index, value)) {
> >      return static_cast<int>(index);
> >
> > Please let me know how do I submit this issue for approval.
> >
> > Thanks,
> > Arkadiy
>


-- 

*James Duong*
Lead Software Developer
Bit Quill Technologies Inc.
Direct: +1.604.562.6082 | jamesd@bitquilltech.com
https://www.bitquilltech.com

This email message is for the sole use of the intended recipient(s) and may
contain confidential and privileged information.  Any unauthorized review,
use, disclosure, or distribution is prohibited.  If you are not the
intended recipient, please contact the sender by reply email and destroy
all copies of the original message.  Thank you.

Re: Cpp Win32/MSVC build

Posted by Sutou Kouhei <ko...@clear-code.com>.
Hi,

Could you open a pull request on
https://github.com/apache/arrow to review the patch?

See also:

  * https://arrow.apache.org/docs/developers/guide/step_by_step/pr_lifecycle.html#create-pr
  * https://arrow.apache.org/docs/developers/overview.html#pull-request-and-review


Thanks,
-- 
kou

In <62...@msllnjpmsgsv06>
  "Cpp Win32/MSVC build" on Tue, 7 Jun 2022 19:34:27 -0000,
  "Arkadiy Vertleyb (BLOOMBERG/ 120 PARK)" <av...@bloomberg.net> wrote:

> Hi all,
> 
> I just created ARROW-16778 to address C++ build issues under MSVC/Win32.  The following patch can fix the issue:
> 
> index 8583e10b2..496bbb78b 100644
> --- a/cpp/src/arrow/util/bit_util.h
> +++ b/cpp/src/arrow/util/bit_util.h
> @@ -67,7 +67,14 @@ static constexpr uint8_t kBytePopcount[] = {
>      5, 4, 5, 5, 6, 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7, 3, 4, 4, 5, 4, 5, 5, 6,
>      4, 5, 5, 6, 5, 6, 6, 7, 4, 5, 5, 6, 5, 6, 6, 7, 5, 6, 6, 7, 6, 7, 7, 8};
> 
> +#if defined(_MSC_VER) && !defined(_M_AMD64) && !defined(_M_X64)
> +static inline uint64_t PopCount(uint64_t bitmap) {
> +  uint32_t* p = reinterpret_cast<uint32_t*>(&bitmap);
> +  return ARROW_POPCOUNT32(*p) + ARROW_POPCOUNT32(*(p + 1));
> +}
> +#else
>  static inline uint64_t PopCount(uint64_t bitmap) { return ARROW_POPCOUNT64(bitmap); }
> +#endif
>  static inline uint32_t PopCount(uint32_t bitmap) { return ARROW_POPCOUNT32(bitmap); }
> 
>  //
> @@ -199,7 +206,7 @@ static inline int CountLeadingZeros(uint64_t value) {
>  #if defined(__clang__) || defined(__GNUC__)
>    if (value == 0) return 64;
>    return static_cast<int>(__builtin_clzll(value));
> -#elif defined(_MSC_VER)
> +#elif defined(_MSC_VER) && (defined(_M_AMD64) || defined(_M_X64))
>    unsigned long index;                     // NOLINT
>    if (_BitScanReverse64(&index, value)) {  // NOLINT
>      return 63 - static_cast<int>(index);
> @@ -220,7 +227,7 @@ static inline int CountTrailingZeros(uint32_t value) {
>  #if defined(__clang__) || defined(__GNUC__)
>    if (value == 0) return 32;
>    return static_cast<int>(__builtin_ctzl(value));
> -#elif defined(_MSC_VER)
> +#elif defined(_MSC_VER) && (defined(_M_AMD64) || defined(_M_X64))
>    unsigned long index;  // NOLINT
>    if (_BitScanForward(&index, value)) {
>      return static_cast<int>(index);
> @@ -245,7 +252,7 @@ static inline int CountTrailingZeros(uint64_t value) {
>  #if defined(__clang__) || defined(__GNUC__)
>    if (value == 0) return 64;
>    return static_cast<int>(__builtin_ctzll(value));
> -#elif defined(_MSC_VER)
> +#elif defined(_MSC_VER) && (defined(_M_AMD64) || defined(_M_X64))
>    unsigned long index;  // NOLINT
>    if (_BitScanForward64(&index, value)) {
>      return static_cast<int>(index);
> 
> Please let me know how do I submit this issue for approval.
> 
> Thanks,
> Arkadiy