Skip to content

Commit

Permalink
Move prefetch to individual header
Browse files Browse the repository at this point in the history
  • Loading branch information
zanmato1984 committed Oct 1, 2024
1 parent d202127 commit 4ddc378
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 10 deletions.
2 changes: 1 addition & 1 deletion cpp/src/arrow/acero/bloom_filter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
#include "arrow/util/bit_util.h" // Log2
#include "arrow/util/bitmap_ops.h" // CountSetBits
#include "arrow/util/config.h"
#include "arrow/util/macros.h" // PREFETCH
#include "arrow/util/prefetch.h" // PREFETCH

namespace arrow {
namespace acero {
Expand Down
9 changes: 0 additions & 9 deletions cpp/src/arrow/util/macros.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@

#include <cstdint>

#include "arrow/util/simd.h"

#define ARROW_EXPAND(x) x
#define ARROW_STRINGIFY(x) #x
#define ARROW_CONCAT(x, y) x##y
Expand Down Expand Up @@ -80,7 +78,6 @@
# define ARROW_FORCE_INLINE __attribute__((always_inline))
# define ARROW_PREDICT_FALSE(x) (__builtin_expect(!!(x), 0))
# define ARROW_PREDICT_TRUE(x) (__builtin_expect(!!(x), 1))
# define ARROW_PREFETCH(addr) __builtin_prefetch(addr)
# define ARROW_RESTRICT __restrict
# if defined(__clang__) // clang-specific
# define ARROW_COMPILER_ASSUME(expr) __builtin_assume(expr)
Expand All @@ -107,11 +104,6 @@
# define ARROW_FORCE_INLINE __forceinline
# define ARROW_PREDICT_FALSE(x) (x)
# define ARROW_PREDICT_TRUE(x) (x)
# if defined(ARROW_HAVE_SSE4_2) || defined(ARROW_HAVE_RUNTIME_SSE4_2)
# define ARROW_PREFETCH(addr) _mm_prefetch((const char*)(addr), _MM_HINT_T0)
# else
# define ARROW_PREFETCH(addr)
# endif
# define ARROW_RESTRICT __restrict
# define ARROW_COMPILER_ASSUME(expr) __assume(expr)
#else
Expand All @@ -120,7 +112,6 @@
# define ARROW_FORCE_INLINE
# define ARROW_PREDICT_FALSE(x) (x)
# define ARROW_PREDICT_TRUE(x) (x)
# define ARROW_PREFETCH(addr)
# define ARROW_RESTRICT
# define ARROW_COMPILER_ASSUME(expr)
#endif
Expand Down
31 changes: 31 additions & 0 deletions cpp/src/arrow/util/prefetch.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
// with the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.

#pragma once

#if defined(__GNUC__) // GCC and compatible compilers (clang, Intel ICC)
# define ARROW_PREFETCH(addr) __builtin_prefetch(addr)
#elif defined(_MSC_VER) // MSVC
# if defined(ARROW_HAVE_SSE4_2) || defined(ARROW_HAVE_RUNTIME_SSE4_2)
# include <nmmintrin.h>
# define ARROW_PREFETCH(addr) _mm_prefetch((const char*)(addr), _MM_HINT_T0)
# else
# define ARROW_PREFETCH(addr)
# endif
#else
# define ARROW_PREFETCH(addr)
#endif

0 comments on commit 4ddc378

Please sign in to comment.