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 6083619
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T11:25:27+00:00 2026-05-23T11:25:27+00:00

I have a small piece of code which runs perfectly on Nvidia old architecture

  • 0

I have a small piece of code which runs perfectly on Nvidia old architecture (Tesla T10 processor) but not on Fermi (Tesla M2090)

I learned that Fermi behaves slightly differently. Due to which unsafe code might work correctly on old architectures, while on Fermi it catches the bug.

But I don’t know how to resolve it.

Here is my code:

__global__ void exec (int *arr_ptr, int size, int *result) {

    int tx = threadIdx.x;
    int ty = threadIdx.y;

    *result = arr_ptr[-2];

}

void run(int *arr_dev, int size, int *result) {

    cudaStream_t stream = 0;
    int *arr_ptr = arr_dev + 5;

    dim3 threads(1,1,1);
    dim3 grid (1,1);

    exec<<<grid, threads, 0, stream>>>(arr_ptr, size, result);

}

since I am accessing arr_ptr[-2], the fermi throws CUDA_EXCEPTION_10, Device Illegal Address. But it is not. The address is legal.

Can anyone help me on this.


My driver code is

int main(){
    int *arr;
    int *arr_dev = NULL;
    int result = 1;

    arr = (int*)malloc(10*sizeof(int));

    for(int i = 0; i < 10; i++)
            arr[i] = i;

    if(arr_dev == NULL)
    {
            cudaMalloc((void**)&arr_dev, 10);
            cudaMemcpy(arr_dev, arr, 10*sizeof(int), cudaMemcpyHostToDevice);
    }

    run(arr_dev, 10, &result);
    printf("%d \n", result);
    return 0;

}

  • 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-23T11:25:28+00:00Added an answer on May 23, 2026 at 11:25 am

    Fermi cards have much better memory protection on the device and will detect out of bounds conditions which will appear to “work” on older cards. Use cuda-memchk (or the cuda-memchk mode in cuda-gdb) to get a better handle on what is going wrong.


    EDIT:

    This is the culprit:

    cudaMalloc((void**)&arr_dev, 10);
    

    which should be

    cudaMalloc((void**)&arr_dev, 10*sizeof(int));
    

    This will result in this code

    int *arr_ptr = arr_dev + 5;
    

    passing a pointer to the device which is out of bounds.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a small piece of code which does something funny, but I can't
I have this small piece of code that basically takes a list and runs
I have written a small piece of code which handles the input of a
I have written a small piece of code to calculate quadratic equations, but if
I have a small piece of code here for your consideration which puzzles me
I have a small piece of c code which should run an awk command
I have a small piece of code that works as a plugin for a
I have a small piece of code that I use to keep track of
I have a relatively small piece of initializer code that I want to run
I have this small piece of code. private void Application_Startup(object sender, StartupEventArgs e) {

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.