Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4043922
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T13:11:19+00:00 2026-05-20T13:11:19+00:00

I have scoured the internets looking for an answer to this one, but couldn’t

  • 0

I have scoured the internets looking for an answer to this one, but couldn’t find any. I’ve installed the CUDA 3.2 SDK (and, just now, CUDA 4.0 RC) and everything seems to work fine after long hours of fooling around with include directories, NSight, and all the rest. Well, except this one thing: it keeps highlighting the <<< >>> operator as a mistake. Only on VS2010–not on VS2008.

On VS2010 I also get several warnings of the following sort:

C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\include\xdebug(109): warning C4251: 'std::_String_val<_Ty,_Alloc>::_Alval' : class 'std::_DebugHeapAllocator<_Ty>' needs to have dll-interface to be used by clients of class 'std::_String_val<_Ty,_Alloc>'

Update: If I try and include an entry point in a .cpp file that calls a CUDA kernel, instead of writing main() in a .cu file as I was doing, the operator is actually flagged as an error, besides highlighting it! The same thing happens with VS2008.

Anyone know how this can be fixed?

Update 2: Here is the code. The main.cpp file:

#include "kernel.cu"

int main()
{
    doStuff();
    return 0;
}

and the .cu file:

#include <iostream>
#include "cuda.h"
#include "cuda_runtime.h"
#include "device_launch_parameters.h"
#include <cutil_inline.h>
#include <time.h>

using namespace std;

#define N 16

__global__ void MatAdd(float A[N][N], float B[N][N], float C[N][N])

{
    int i = blockIdx.x * blockDim.x + threadIdx.x;
int j = blockIdx.y * blockDim.y + threadIdx.y;

if (i < N && j < N)
    C[i][j] = A[i][j] + B[i][j];
}

int doStuff()
{
    dim3 threadsPerBlock(8, 8);
    dim3 numBlocks(N / threadsPerBlock.x, N / threadsPerBlock.y);

    float A[N][N], B[N][N], C[N][N];

    for (int i = 0; i < N; ++i)
        for (int j = 0; j < N; ++j)
        {
            A[i][j] = 0;
            B[i][j] = 0;
            C[i][j] = 0;
        }

    clock_t start = clock();
    MatAdd<<<numBlocks, threadsPerBlock>>>(A, B, C);
    clock_t end = clock();

    cout << "Took " << float(end - start) << "ms to work out." << endl;
    cin.get();

    return 0;
}

Update 3: Alright, I was (idiotically) including the CUDA code in the .cpp file, so of course it couldn’t compile. Now I have CUDA 4.0 up and running on VS2010, but I still get several warnings of the kind explained above.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T13:11:20+00:00Added an answer on May 20, 2026 at 1:11 pm

    You cannot do this…

    #include "kernel.cu" 
    

    Now you’re asking the Visual Studio CPP compiler to compile the .CU file as though it was a header. You need to have a header file that declares doStuff() and include the header not the definition.

    The following might be helpful.

    http://www.ademiller.com/blogs/tech/2010/12/using-cudathrust-with-the-parallel-patterns-library/

    http://blog.cuvilib.com/2011/02/24/how-to-run-cuda-in-visual-studio-2010/

    Typically I set this up as two projects. One project that compiles against the the 2008 CPP compiler for .CU and another that uses the 2010 compiler to get all the C++0x features.

    The warnings your getting can be fixed by exporting the appropriate templates. Something like this but you’ll have to write a specific one for each of the warning types.

    #if defined(__CUDACC__)
    #define DECLSPECIFIER  __declspec(dllexport)
    #define EXPIMP_TEMPLATE
    
    #else
    #define DECLSPECIFIER  __declspec(dllimport)
    #define EXPIMP_TEMPLATE extern
    #endif
    
    EXPIMP_TEMPLATE template class DECLSPECIFIER thrust::device_vector<unsigned long>;
    

    See:

    http://support.microsoft.com/default.aspx?scid=KB;EN-US;168958 and
    http://msdn.microsoft.com/en-us/library/esew7y1w.aspx

    I’ve written a step-by-step guide to setting up VS 2010 and CUDA 4.0 here

    http://www.ademiller.com/blogs/tech/2011/03/using-cuda-and-thrust-with-visual-studio-2010/

    BTW: A better way of timing CUDA code is with the event API.

    cudaEvent_t start, stop; 
    float time;
    cudaEventCreate(&start);
    cudaEventCreate(&stop); 
    cudaEventRecord( start, 0 ); 
    kernel<<<grid,threads>>> ( d_odata, d_idata, size_x, size_y, NUM_REPS); 
    cudaEventRecord( stop, 0 ); 
    cudaEventSynchronize( stop ); 
    cudaEventElapsedTime( &time, start, stop );
    cudaEventDestroy( start );
    cudaEventDestroy( stop );
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have scoured the web in search of a solution to this problem, but
Ok. I have scoured for hours. I can't seem to find the answer to
I have scoured this site among others for answers in getting OpenEntityManagerInViewFilter to work.
I have scoured the web for a decent explanation of the routing syntax in
Have you ever seen any of there error messages? -- SQL Server 2000 Could
Have you guys had any experiences (positive or negative) by placing your source code/solution
Have you managed to get Aptana Studio debugging to work? I tried following this,
I recently installed Rails on a cpanel machine using this guide: http://www.cpanel.net/blog/cpanel-whm-admins/2011/07/installing-mod-rails-and-rails-309-on-a-cpanel-machine.html When I
Have just started using Google Chrome , and noticed in parts of our site,
Have just started using Visual Studio Professional's built-in unit testing features, which as I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.