Fix GPU build failures.

This commit is contained in:
Antonio Sanchez
2025-03-09 17:04:41 -07:00
parent 6a4a0b66bd
commit 952eda443b
7 changed files with 37 additions and 24 deletions

View File

@@ -52,11 +52,14 @@
#endif
#ifdef _WIN32
#define NOMINMAX
#include <windows.h>
#elif defined(__APPLE__)
#include <mach/mach_time.h>
#include <unistd.h>
#else
#include <time.h>
#include <unistd.h>
#endif
#ifdef EIGEN_USE_THREADS
@@ -68,7 +71,8 @@
#include <cuda_runtime.h>
#if __cplusplus >= 201103L
#include <atomic>
#include <unistd.h>
#include <chrono>
#include <thread>
#endif
#endif

View File

@@ -700,7 +700,7 @@ __global__ void EigenConvolutionKernel3D(
const int last_z = (first_z + maxZ < numZ ? first_z + maxZ : numZ) - 1;
const int num_z_input = last_z - first_z + kernelSizeZ;
for (int p = 0; p < numPlanes; ++p) {
for (size_t p = 0; p < numPlanes; ++p) {
const int plane_input_offset = indexMapper.mapCudaInputPlaneToTensorInputOffset(p);
const int plane_kernel_offset = 0;
@@ -726,9 +726,9 @@ __global__ void EigenConvolutionKernel3D(
for (int j = threadIdx.y; j < num_y_output; j += blockDim.y) {
for (int i = threadIdx.x; i < num_x_output; i += blockDim.x) {
float result = 0.0f;
for (int n = 0; n < kernelSizeZ; ++n) {
for (int m = 0; m < kernelSizeY; ++m) {
for (int l = 0; l < kernelSizeX; ++l) {
for (size_t n = 0; n < kernelSizeZ; ++n) {
for (size_t m = 0; m < kernelSizeY; ++m) {
for (size_t l = 0; l < kernelSizeX; ++l) {
result += s[i + l + num_x_input * (j + m + num_y_input * (k + n + plane_kernel_offset))] * kernel[l + kernelSizeX * (m + kernelSizeY * n)];
}
}

View File

@@ -38,7 +38,7 @@ class StreamInterface {
};
static cudaDeviceProp* m_deviceProperties;
static bool m_devicePropInitialized = false;
static volatile bool m_devicePropInitialized = false;
static void initializeDeviceProp() {
if (!m_devicePropInitialized) {
@@ -87,8 +87,12 @@ static void initializeDeviceProp() {
while (!m_devicePropInitialized) {
#if __cplusplus >= 201103L
std::atomic_thread_fence(std::memory_order_acquire);
#endif
std::this_thread::sleep_for(std::chrono::milliseconds(1000));
#elif defined(_WIN32)
Sleep(1);
#else
sleep(1);
#endif
}
}
}
@@ -214,10 +218,13 @@ struct GpuDevice {
#ifndef __CUDA_ARCH__
cudaError_t err = cudaMemcpyAsync(dst, src, n, cudaMemcpyDeviceToDevice,
stream_->stream());
EIGEN_UNUSED_VARIABLE(err)
EIGEN_ONLY_USED_FOR_DEBUG(err);
assert(err == cudaSuccess);
#else
eigen_assert(false && "The default device should be used instead to generate kernel code");
EIGEN_UNUSED_VARIABLE(dst);
EIGEN_UNUSED_VARIABLE(src);
EIGEN_UNUSED_VARIABLE(n);
eigen_assert(false && "The default device should be used instead to generate kernel code");
#endif
}

View File

@@ -169,6 +169,7 @@ template <typename T> class array<T, 0> {
#if EIGEN_HAS_VARIADIC_TEMPLATES
EIGEN_DEVICE_FUNC array(std::initializer_list<T> l) : dummy() {
EIGEN_ONLY_USED_FOR_DEBUG(l);
eigen_assert(l.size() == 0);
}
#endif