Results 1 to 2 of 2

Thread: CUDA 2D Array Problems

  1. #1
    Odc
    Odc is offline
    Sonic Boom! Odc's Avatar
    Join Date
    Aug 2005
    Location
    Hertfordshire
    Posts
    1,537
    Thanks
    26
    Thanked
    18 times in 17 posts
    • Odc's system
      • Motherboard:
      • Gigabyte Z77-D3H
      • CPU:
      • Core i5 3570k
      • Memory:
      • 8GB Corsair XMS3
      • Storage:
      • 500GB Corsair MX100, 500Gb Samsung
      • Graphics card(s):
      • SLI Zotac GTX 560 Ti 448
      • PSU:
      • 750W Enermax
      • Case:
      • CoolerMaster Centurion 5
      • Operating System:
      • Windows 7 Professional x64
      • Monitor(s):
      • Dell SP2309W
      • Internet:
      • BT Infinity 2

    CUDA 2D Array Problems

    Hi all, I've posted this over at the Nvidia forums as well but thought I'd try my luck here too

    Original Post:

    I've just started to learn CUDA and have created a simple program that creates a 2D array of int, assigns the memory on the device and then copies the array onto the device. Eventually I want to expand this into a graph searching algorithm. However, when using an array with 1,000 verticies (indicies) it simply crashes. As far as I can tell, its populating the array on the host that causes the crash.

    Call me a noob but I thought that an array of this size was perfectly acceptable?

    Here's my code anyway

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

    __global__ void myKernel(int* deviceArrayPtr, int pitch)
    {

    }

    main()
    {
    int* deviceArrayPtr;
    size_t devicePitch, hostPitch, width, height;
    int hostArray[1000][1000];

    width = 1000;
    height = 1000;
    for(int i = 0; i < 1000; i ++)
    for(int j = 0; j < 1000; j ++)
    hostArray[i][j] = 20; //20 is an abitrary number

    //Allocates memory on the device
    cudaMallocPitch((void**)&deviceArrayPtr, &devicePitch, width * sizeof(int), height);

    hostPitch = devicePitch;

    //Copies hostArray onto the pre-allocated device memory
    cudaMemcpy2D(deviceArrayPtr, devicePitch, &hostArray, hostPitch, width * sizeof(int), height, cudaMemcpyHostToDevice);

    myKernel <<< 100, 512 >>> (deviceArrayPtr, devicePitch);
    }


    Anyone have any ideas about this?


    Hexus Trust = Odesi

  2. #2
    Gentoo Ricer
    Join Date
    Jan 2005
    Location
    Galway
    Posts
    11,048
    Thanks
    1,016
    Thanked
    944 times in 704 posts
    • aidanjt's system
      • Motherboard:
      • Asus Strix Z370-G
      • CPU:
      • Intel i7-8700K
      • Memory:
      • 2x8GB Corsiar LPX 3000C15
      • Storage:
      • 500GB Samsung 960 EVO
      • Graphics card(s):
      • EVGA GTX 970 SC ACX 2.0
      • PSU:
      • EVGA G3 750W
      • Case:
      • Fractal Design Define C Mini
      • Operating System:
      • Windows 10 Pro
      • Monitor(s):
      • Asus MG279Q
      • Internet:
      • 240mbps Virgin Cable

    Re: CUDA 2D Array Problems

    The array fill loop code is fine. It's likely your cuda calls which are the problem.
    Last edited by aidanjt; 19-10-2009 at 04:56 PM.
    Quote Originally Posted by Agent View Post
    ...every time Creative bring out a new card range their advertising makes it sound like they have discovered a way to insert a thousand Chuck Norris super dwarfs in your ears...

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Problems with Abit Netherlands Tech Support.
    By CJShielder in forum abit.care@HEXUS
    Replies: 4
    Last Post: 18-04-2008, 09:24 AM
  2. Replies: 15
    Last Post: 31-07-2006, 06:13 PM
  3. Cloning a Raid0 to a Raid5 array
    By Stephen B in forum Software
    Replies: 5
    Last Post: 29-06-2005, 09:35 AM
  4. Troubleshooting - Software & Driver problems
    By Steve in forum Help! Quick Relief From Tech Headaches
    Replies: 0
    Last Post: 09-07-2004, 06:30 PM
  5. more VBA and SQL 'problems'...
    By streetster in forum Software
    Replies: 7
    Last Post: 07-01-2004, 10:45 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •