2017-02-22 23:26:44 +01:00
|
|
|
/**
|
|
|
|
* Copyright (c) 2015-present, Facebook, Inc.
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
2017-07-30 00:18:45 -07:00
|
|
|
* This source code is licensed under the BSD+Patents license found in the
|
2017-02-22 23:26:44 +01:00
|
|
|
* LICENSE file in the root directory of this source tree.
|
|
|
|
*/
|
|
|
|
|
|
|
|
// Copyright 2004-present Facebook. All Rights Reserved.
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
namespace faiss { namespace gpu {
|
|
|
|
|
|
|
|
#ifdef __CUDA_ARCH__
|
2017-11-23 06:34:53 -08:00
|
|
|
#if __CUDA_ARCH__ <= 700
|
2017-02-22 23:26:44 +01:00
|
|
|
constexpr int kWarpSize = 32;
|
|
|
|
#else
|
|
|
|
#error Unknown __CUDA_ARCH__; please define parameters for compute capability
|
|
|
|
#endif // __CUDA_ARCH__ types
|
|
|
|
#endif // __CUDA_ARCH__
|
|
|
|
|
|
|
|
#ifndef __CUDA_ARCH__
|
|
|
|
// dummy value for host compiler
|
|
|
|
constexpr int kWarpSize = 32;
|
|
|
|
#endif // !__CUDA_ARCH__
|
|
|
|
|
2017-11-23 06:34:53 -08:00
|
|
|
// This is a memory barrier for intra-warp writes to shared memory.
|
2017-02-22 23:26:44 +01:00
|
|
|
__forceinline__ __device__ void warpFence() {
|
|
|
|
|
2017-11-23 06:34:53 -08:00
|
|
|
#if __CUDA_ARCH__ >= 700
|
|
|
|
__syncwarp();
|
|
|
|
#else
|
|
|
|
// For the time being, assume synchronicity.
|
2017-02-22 23:26:44 +01:00
|
|
|
// __threadfence_block();
|
2017-11-23 06:34:53 -08:00
|
|
|
#endif
|
2017-02-22 23:26:44 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
} } // namespace
|