View Issue Details Jump to Notes ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0010586CMakeModulespublic2010-04-21 05:162011-01-19 18:55
ReporterMrNightLifeLover 
Assigned ToJames Bigler 
PrioritynormalSeveritymajorReproducibilityalways
StatusclosedResolutionfixed 
PlatformOSOS Version
Product VersionCMake-2-8 
Target VersionCMake-2-8Fixed in VersionCMake-2-8 
Summary0010586: Emulation mode does not work when using cmake with CUDA 3.0
DescriptionI'm trying to use CUDA with cmake (v 2.8) on my Mac (OSX 10.6). So far it works fine, I created a small sample just to try it out (see below). However when I switch on emulation mode, it cannot invoke the CUDA kernel anymore and I get the following error message:

Cuda error: kernel invocation: invalid device function .

I also tried to compile it by invoking nvcc by hand and didn't get the error message, so I think it could be a problem with cmake. I also tried the it on Linux (64bit) and ended up with the same result: It works when not using emulation mode, when I enable emulation mode I'm stuck with the same error.
Additional InformationBelow the files

CMakeLists.txt

cmake_minimum_required(VERSION 2.8)
project (test)

find_package(CUDA)
add_definitions(-Wall)

# Use CUDA emulator?
set(CUDA_BUILD_EMULATION ON)
set(CUDA_64_BIT_DEVICE_CODE OFF) # Does not work on a Mac currently
set(CMAKE_C_FLAGS -m32)
set(CMAKE_CXX_FLAGS -m32)
set(CUDA_VERBOSE_BUILD ON)

include_directories("${PROJECT_BINARY_DIR}")

cuda_add_executable(test
    test.cu
)
test.cu

#include <cuda.h>
#include <stdlib.h>
#include <stdio.h>

#include "test_kernel.cu"

void checkCUDAError(const char *msg);

int main( int argc, const char** argv )
{
    int n = 3;
    float* a_h;
    a_h = (float *)malloc(sizeof(float)*n);
    float* a_d;
    cudaMalloc((void**) &a_d, sizeof(float)*n);

    hello<<<1,128>>>(a_d, n);
    checkCUDAError("kernel invocation");
    checkCUDAError("memcpy");

    free(a_h);
    cudaFree(a_d);

    return 0;
}

void checkCUDAError(const char *msg)
{
    cudaError_t err = cudaGetLastError();
    if( cudaSuccess != err)
    {
        fprintf(stderr, "Cuda error: %s: %s.\n", msg,
                cudaGetErrorString( err) );
        exit(EXIT_FAILURE);
    }
}
test_kernel.cu

#include <stdio.h>

__global__ void hello(float*a, int i)
{
    int j = i+1;
#ifdef _DEVICEEMU
    printf("Hello.\n");
#endif
}
TagsNo tags attached.
Attached Files

 Relationships

  Notes
(0024807)
David Cole (manager)
2011-01-17 15:49

James, do you see anything wrong with his code? Or with FindCUDA?

Thanks.
(0024935)
James Bigler (developer)
2011-01-19 17:34

I just tried this on my Mac, and it worked file with a 2.8.2 version distributed from Mac ports. There was a problem with emulation I fixed where there was a new cudartemu library in CUDA 3.0.

http://cmake.org/gitweb?p=cmake.git;a=commit;h=bb6acb8667c98bfa4210da84678fdcb2df42a433 [^]

You should update to at least 2.8.2 to fix this issue.
(0024936)
James Bigler (developer)
2011-01-19 17:35

This should be fixed in 2.8.2 as I verified with the reproducer.

 Issue History
Date Modified Username Field Change
2010-04-21 05:16 MrNightLifeLover New Issue
2011-01-17 15:48 David Cole Assigned To => James Bigler
2011-01-17 15:48 David Cole Status new => assigned
2011-01-17 15:49 David Cole Note Added: 0024807
2011-01-19 17:34 James Bigler Note Added: 0024935
2011-01-19 17:35 James Bigler Note Added: 0024936
2011-01-19 17:35 James Bigler Status assigned => closed
2011-01-19 17:35 James Bigler Resolution open => fixed
2011-01-19 18:55 David Cole Fixed in Version => CMake-2-8
2011-01-19 18:55 David Cole Target Version => CMake-2-8


Copyright © 2000 - 2018 MantisBT Team