Pause.h#
Fully qualified name: carb/Pause.h
File members: carb/Pause.h
// SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
// SPDX-License-Identifier: LicenseRef-NvidiaProprietary
//
// NVIDIA CORPORATION, its affiliates and licensors retain all intellectual
// property and proprietary rights in and to this material, related
// documentation and any modifications thereto. Any use, reproduction,
// disclosure or distribution of this material and related documentation
// without an express license agreement from NVIDIA CORPORATION or
// its affiliates is strictly prohibited.
#pragma once
#include "Architecture.h"
#include "Compiler.h"
// Implement CARB_HARDWARE_PAUSE; a way of idling the pipelines and reducing the penalty
// from memory order violations. See
// https://software.intel.com/en-us/articles/long-duration-spin-wait-loops-on-hyper-threading-technology-enabled-intel-processors
#ifdef DOXYGEN_BUILD
# define CARB_HARDWARE_PAUSE()
#elif CARB_X86_64
// avoid including immintrin.h
# if CARB_COMPILER_MSC
extern "C" void _mm_pause(void);
# pragma intrinsic(_mm_pause)
# define CARB_HARDWARE_PAUSE() _mm_pause()
# else
# define CARB_HARDWARE_PAUSE() __builtin_ia32_pause()
# endif
#elif defined(__aarch64__)
# define CARB_HARDWARE_PAUSE() __asm__ __volatile__("yield" ::: "memory")
#elif defined(_M_ARM64)
# define CARB_HARDWARE_PAUSE() __yield()
#else
CARB_UNSUPPORTED_PLATFORM();
#endif