Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simplify cudacompat layer to use a 1-dimensional grid #32586

Merged
merged 1 commit into from
Dec 26, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 15 additions & 33 deletions HeterogeneousCore/CUDAUtilities/interface/cudaCompat.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,26 @@
#include <cstdint>
#include <cstring>

// include the CUDA runtime header to define some of the attributes, types and sybols also on the CPU
#include <cuda_runtime.h>

// make sure function are inlined to avoid multiple definition
#undef __global__
#define __global__ inline __attribute__((always_inline))

#undef __forceinline__
#define __forceinline__ inline __attribute__((always_inline))

namespace cms {
namespace cudacompat {

#ifndef __CUDA_RUNTIME_H__
struct dim3 {
uint32_t x, y, z;
};
#endif
// run serially with a single thread
// 1-dimensional block
const dim3 threadIdx = {0, 0, 0};
const dim3 blockDim = {1, 1, 1};

extern thread_local dim3 blockIdx;
extern thread_local dim3 gridDim;
// 1-dimensional grid
const dim3 blockIdx = {0, 0, 0};
const dim3 gridDim = {1, 1, 1};

template <typename T1, typename T2>
T1 atomicCAS(T1* address, T1 compare, T2 val) {
Expand Down Expand Up @@ -78,35 +83,12 @@ namespace cms {
return *x;
}

inline void resetGrid() {
blockIdx = {0, 0, 0};
gridDim = {1, 1, 1};
}

} // namespace cudacompat
} // namespace cms

// some not needed as done by cuda runtime...
#ifndef __CUDA_RUNTIME_H__
#define __host__
#define __device__
#define __global__
#define __shared__
#define __forceinline__
#endif

// make sure function are inlined to avoid multiple definition
#ifndef __CUDA_ARCH__
#undef __global__
#define __global__ inline __attribute__((always_inline))
#undef __forceinline__
#define __forceinline__ inline __attribute__((always_inline))
#endif

#ifndef __CUDA_ARCH__
// make the cudacompat implementation available in the global namespace
using namespace cms::cudacompat;
#endif

#endif
#endif // __CUDACC__

#endif // HeterogeneousCore_CUDAUtilities_interface_cudaCompat_h
17 changes: 0 additions & 17 deletions HeterogeneousCore/CUDAUtilities/src/cudaCompat.cc

This file was deleted.