Missing <target>_EXPORTS definition in CUDA host compilation

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Missing <target>_EXPORTS definition in CUDA host compilation

Hancox, James

Hi,

 

I’m trying out the new CUDA support for Visual Studio generators in Cmake 3.9.0-rc3 (generator Visual Studio 12 2013 Win64), and I think I’ve found a bug.

 

Our code defines some DLL-export functions in host code in a .cu file, but it seems that the usual <target>_EXPORTS pre-processor definition is missing for host code compilation invoked from NVCC. We have the usual DLL boilerplate defined in a header like so:

 

#ifdef example_target_EXPORTS

#define EXAMPLE_TARGET_API _declspec(dllexport)

#else

#define EXAMPLE_TARGET_API _declspec(dllimport)

#endif

 

However in my .cu file, EXAMPLE_TARGET_API is being expanded to _declspec(dllimport), not _declspec(dllexport) . It would appear that example_target_EXPORTS is not being declared.

 

Is this intended behaviour, or a bug? If intended behaviour, what is the mechanism I should be using instead?

 

Many thanks,

James Hancox


______________________________________________________________________
This email has been scanned by the Symantec Email Security.cloud service.
For more information please visit http://www.symanteccloud.com
______________________________________________________________________

--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Missing <target>_EXPORTS definition in CUDA host compilation

Robert Maynard
Hi James,

I have created a bug report for this issue, which you can track at:
https://gitlab.kitware.com/cmake/cmake/issues/16993

On Fri, Jun 16, 2017 at 12:14 PM, Hancox, James <[hidden email]> wrote:

> Hi,
>
>
>
> I’m trying out the new CUDA support for Visual Studio generators in Cmake
> 3.9.0-rc3 (generator Visual Studio 12 2013 Win64), and I think I’ve found a
> bug.
>
>
>
> Our code defines some DLL-export functions in host code in a .cu file, but
> it seems that the usual <target>_EXPORTS pre-processor definition is missing
> for host code compilation invoked from NVCC. We have the usual DLL
> boilerplate defined in a header like so:
>
>
>
> #ifdef example_target_EXPORTS
>
> #define EXAMPLE_TARGET_API _declspec(dllexport)
>
> #else
>
> #define EXAMPLE_TARGET_API _declspec(dllimport)
>
> #endif
>
>
>
> However in my .cu file, EXAMPLE_TARGET_API is being expanded to
> _declspec(dllimport), not _declspec(dllexport) . It would appear that
> example_target_EXPORTS is not being declared.
>
>
>
> Is this intended behaviour, or a bug? If intended behaviour, what is the
> mechanism I should be using instead?
>
>
>
> Many thanks,
>
> James Hancox
>
>
> ______________________________________________________________________
> This email has been scanned by the Symantec Email Security.cloud service.
> For more information please visit http://www.symanteccloud.com
> ______________________________________________________________________
>
> --
>
> Powered by www.kitware.com
>
> Please keep messages on-topic and check the CMake FAQ at:
> http://www.cmake.org/Wiki/CMake_FAQ
>
> Kitware offers various services to support the CMake community. For more
> information on each offering, please visit:
>
> CMake Support: http://cmake.org/cmake/help/support.html
> CMake Consulting: http://cmake.org/cmake/help/consulting.html
> CMake Training Courses: http://cmake.org/cmake/help/training.html
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Follow this link to subscribe/unsubscribe:
> http://public.kitware.com/mailman/listinfo/cmake
--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Missing <target>_EXPORTS definition in CUDA host compilation

Robert Maynard
Hi James,

In testing we have not been able to replicate the reported behavior.
We are seeing that the .cu files inside a shared library have the
correct export defines setup.

On Mon, Jun 19, 2017 at 8:23 AM, Robert Maynard
<[hidden email]> wrote:

> Hi James,
>
> I have created a bug report for this issue, which you can track at:
> https://gitlab.kitware.com/cmake/cmake/issues/16993
>
> On Fri, Jun 16, 2017 at 12:14 PM, Hancox, James <[hidden email]> wrote:
>> Hi,
>>
>>
>>
>> I’m trying out the new CUDA support for Visual Studio generators in Cmake
>> 3.9.0-rc3 (generator Visual Studio 12 2013 Win64), and I think I’ve found a
>> bug.
>>
>>
>>
>> Our code defines some DLL-export functions in host code in a .cu file, but
>> it seems that the usual <target>_EXPORTS pre-processor definition is missing
>> for host code compilation invoked from NVCC. We have the usual DLL
>> boilerplate defined in a header like so:
>>
>>
>>
>> #ifdef example_target_EXPORTS
>>
>> #define EXAMPLE_TARGET_API _declspec(dllexport)
>>
>> #else
>>
>> #define EXAMPLE_TARGET_API _declspec(dllimport)
>>
>> #endif
>>
>>
>>
>> However in my .cu file, EXAMPLE_TARGET_API is being expanded to
>> _declspec(dllimport), not _declspec(dllexport) . It would appear that
>> example_target_EXPORTS is not being declared.
>>
>>
>>
>> Is this intended behaviour, or a bug? If intended behaviour, what is the
>> mechanism I should be using instead?
>>
>>
>>
>> Many thanks,
>>
>> James Hancox
>>
>>
>> ______________________________________________________________________
>> This email has been scanned by the Symantec Email Security.cloud service.
>> For more information please visit http://www.symanteccloud.com
>> ______________________________________________________________________
>>
>> --
>>
>> Powered by www.kitware.com
>>
>> Please keep messages on-topic and check the CMake FAQ at:
>> http://www.cmake.org/Wiki/CMake_FAQ
>>
>> Kitware offers various services to support the CMake community. For more
>> information on each offering, please visit:
>>
>> CMake Support: http://cmake.org/cmake/help/support.html
>> CMake Consulting: http://cmake.org/cmake/help/consulting.html
>> CMake Training Courses: http://cmake.org/cmake/help/training.html
>>
>> Visit other Kitware open-source projects at
>> http://www.kitware.com/opensource/opensource.html
>>
>> Follow this link to subscribe/unsubscribe:
>> http://public.kitware.com/mailman/listinfo/cmake
--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Missing <target>_EXPORTS definition in CUDA host compilation

Hancox, James
Hi Robert,

Thanks for taking the time to look into this. Strange that it isn't reproducing for you! I've made a minimal test case that reproduces the bug, and put it on github:

https://github.com/jameshancox/cmake_example_16993 

I am using:

Visual Studio Professional 2013 Update 5
CUDA 8.0.44
cmake 3.9.0.rc3

The bug is reproducible for both Win32 and x64 generators.

If you still can't reproduce it, let me know and I'll try to figure out what's going on.

Cheers,
James

-----Original Message-----
From: Robert Maynard [mailto:[hidden email]]
Sent: 19 June 2017 18:47
To: Hancox, James <[hidden email]>
Cc: [hidden email]
Subject: Re: [CMake] Missing <target>_EXPORTS definition in CUDA host compilation

Hi James,

In testing we have not been able to replicate the reported behavior.
We are seeing that the .cu files inside a shared library have the correct export defines setup.

On Mon, Jun 19, 2017 at 8:23 AM, Robert Maynard <[hidden email]> wrote:

> Hi James,
>
> I have created a bug report for this issue, which you can track at:
> https://gitlab.kitware.com/cmake/cmake/issues/16993
>
> On Fri, Jun 16, 2017 at 12:14 PM, Hancox, James <[hidden email]> wrote:
>> Hi,
>>
>>
>>
>> I’m trying out the new CUDA support for Visual Studio generators in
>> Cmake
>> 3.9.0-rc3 (generator Visual Studio 12 2013 Win64), and I think I’ve
>> found a bug.
>>
>>
>>
>> Our code defines some DLL-export functions in host code in a .cu
>> file, but it seems that the usual <target>_EXPORTS pre-processor
>> definition is missing for host code compilation invoked from NVCC. We
>> have the usual DLL boilerplate defined in a header like so:
>>
>>
>>
>> #ifdef example_target_EXPORTS
>>
>> #define EXAMPLE_TARGET_API _declspec(dllexport)
>>
>> #else
>>
>> #define EXAMPLE_TARGET_API _declspec(dllimport)
>>
>> #endif
>>
>>
>>
>> However in my .cu file, EXAMPLE_TARGET_API is being expanded to
>> _declspec(dllimport), not _declspec(dllexport) . It would appear that
>> example_target_EXPORTS is not being declared.
>>
>>
>>
>> Is this intended behaviour, or a bug? If intended behaviour, what is
>> the mechanism I should be using instead?
>>
>>
>>
>> Many thanks,
>>
>> James Hancox
>>
>>
>> _____________________________________________________________________
>> _ This email has been scanned by the Symantec Email Security.cloud
>> service.
>> For more information please visit http://www.symanteccloud.com 
>> _____________________________________________________________________
>> _
>>
>> --
>>
>> Powered by www.kitware.com
>>
>> Please keep messages on-topic and check the CMake FAQ at:
>> http://www.cmake.org/Wiki/CMake_FAQ
>>
>> Kitware offers various services to support the CMake community. For
>> more information on each offering, please visit:
>>
>> CMake Support: http://cmake.org/cmake/help/support.html
>> CMake Consulting: http://cmake.org/cmake/help/consulting.html
>> CMake Training Courses: http://cmake.org/cmake/help/training.html
>>
>> Visit other Kitware open-source projects at
>> http://www.kitware.com/opensource/opensource.html
>>
>> Follow this link to subscribe/unsubscribe:
>> http://public.kitware.com/mailman/listinfo/cmake

______________________________________________________________________
This email has been scanned by the Symantec Email Security.cloud service.
For more information please visit http://www.symanteccloud.com ______________________________________________________________________

______________________________________________________________________
This email has been scanned by the Symantec Email Security.cloud service.
For more information please visit http://www.symanteccloud.com
______________________________________________________________________
--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Missing <target>_EXPORTS definition in CUDA host compilation

Brad King
On 06/20/2017 06:03 AM, Hancox, James wrote:
> https://github.com/jameshancox/cmake_example_16993 

Thanks for the example.  Also, thanks for trying the release candidate!

> Visual Studio Professional 2013 Update 5
> CUDA 8.0.44
> cmake 3.9.0.rc3

I'm not able to reproduce it using VS 2013 Update 5, CMake 3.9.0-rc3,
and CUDA 8.0.61.  Only the CUDA version is different.

IIRC we did encounter some problems with preprocessor definitions
not being properly used by the CUDA VS Integration while developing
the support in CMake.  Upgrading from CUDA 8.0.44 to 8.0.61 fixed them.

Please verify that the definition appears in the .vcxproj file.
If so, then please try updating your CUDA version.

Thanks,
-Brad

--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Missing <target>_EXPORTS definition in CUDA host compilation

Hancox, James
Hi Brad,

I swapped out CUDA 8.0.44 for CUDA 8.0.61, and my problem magically went away. Thanks a lot for the help, I never would have made that connection!

I checked the .vcxproj file before regenerating, and the _EXPORTS define was right where it should be, so it definitely seems like a bug in the VS plugin. We previously used FindCUDA (which doesn't use the plugin) and never ran into that problem, so I hadn't even considered it as a possibility. It might be worth adding a warning/diagnostic to let people know that 8.0.44 has bugs in the VS integration? Will probably save you a lot of similar bug reports in the future.

Thanks again,
James

-----Original Message-----
From: Brad King [mailto:[hidden email]]
Sent: 20 June 2017 14:42
To: Hancox, James <[hidden email]>
Cc: Robert Maynard <[hidden email]>; [hidden email]
Subject: Re: [CMake] Missing <target>_EXPORTS definition in CUDA host compilation

On 06/20/2017 06:03 AM, Hancox, James wrote:
> https://github.com/jameshancox/cmake_example_16993

Thanks for the example.  Also, thanks for trying the release candidate!

> Visual Studio Professional 2013 Update 5 CUDA 8.0.44 cmake 3.9.0.rc3

I'm not able to reproduce it using VS 2013 Update 5, CMake 3.9.0-rc3, and CUDA 8.0.61.  Only the CUDA version is different.

IIRC we did encounter some problems with preprocessor definitions not being properly used by the CUDA VS Integration while developing the support in CMake.  Upgrading from CUDA 8.0.44 to 8.0.61 fixed them.

Please verify that the definition appears in the .vcxproj file.
If so, then please try updating your CUDA version.

Thanks,
-Brad


______________________________________________________________________
This email has been scanned by the Symantec Email Security.cloud service.
For more information please visit http://www.symanteccloud.com ______________________________________________________________________

______________________________________________________________________
This email has been scanned by the Symantec Email Security.cloud service.
For more information please visit http://www.symanteccloud.com
______________________________________________________________________
--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Missing <target>_EXPORTS definition in CUDA host compilation

Brad King
On 06/20/2017 10:10 AM, Hancox, James wrote:
> I swapped out CUDA 8.0.44 for CUDA 8.0.61, and my problem magically
> went away.

Great!  Thanks for testing and reporting back.

> It might be worth adding a warning/diagnostic to let people know
> that 8.0.44 has bugs in the VS integration?

Yes, I've re-opened issue 16993.  We can at least document this.

Thanks,
-Brad

--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake
Loading...