Return to Video

CUDA Program Diagram - Intro to Parallel Programming

  • 0:00 - 0:04
    The computers we're using in this class are termed heterogeneous.
  • 0:04 - 0:08
    They have two different processors in them, the CPU and the GPU.
  • 0:08 - 0:15
    Now, if you write a plain C program, your code will only allow you to use the CPU to run your program.
  • 0:15 - 0:18
    So how do we write code that will run on the GPU?
  • 0:18 - 0:20
    That's where CUDA comes in.
  • 0:20 - 0:25
    The CUDA programming model allows us to program both processors with one program
  • 0:25 - 0:28
    so that we can use the power of the GPU in our programs.
  • 0:28 - 0:32
    CUDA supports numerous languages, but in this class we're using C.
  • 0:32 - 0:37
    Now, part of your CUDA program is plain C and it will run on your CPU.
  • 0:37 - 0:39
    CUDA calls this the host.
  • 0:39 - 0:43
    The other part of your problem will run on the GPU in parallel.
  • 0:43 - 0:46
    It's also written in C but with some extensions that we use to express parallelism.
  • 0:46 - 0:50
    The CUDA term for your GPU is the device.
  • 0:50 - 0:54
    Then, the CUDA compiler will compile your program, split it into pieces
  • 0:54 - 0:59
    that will run on the CPU and the GPU, and generate code for each.
  • 0:59 - 1:05
    CUDA assumes that the device, the GPU, is a co-processor to the host, the CPU.
  • 1:05 - 1:11
    It also assumes that both the host and the device have their own separate memories where they store data.
  • 1:11 - 1:15
    In the systems we use in this class, both the CPU and the GPU
  • 1:15 - 1:18
    have their own physical dedicated memory in the form of DRAM,
  • 1:18 - 1:23
    with the GPU's memory typically being a very high performance block of memory.
  • 1:23 - 1:28
    Now, in this relationship between CPU and GPU, the CPU is in charge.
  • 1:28 - 1:33
    It runs the main program, and it sends directions to the GPU to tell it what to do.
  • 1:33 - 1:37
    It's the part of the system that's responsible for the following.
  • 1:37 - 1:41
    One, moving data from the CPU's memory to the GPU's memory.
  • 1:41 - 1:45
    Two, moving data from the GPU back to the CPU.
  • 1:45 - 1:50
    Now, in the C programming language, moving data from one place to another is called Memcpy.
  • 1:50 - 1:55
    So, it makes sense that in CUDA, this command, either moving data from the CPU to the GPU
  • 1:55 - 1:59
    or moving data from the GPU to the CPU, is called cudaMemcpy.
  • 1:59 - 2:05
    Three, allocating memory on the GPU, and in C this command is Malloc, so in CUDA, it's cudaMalloc.
  • 2:05 - 2:10
    And four, invoking programs on the GPU that compute things in parallel.
  • 2:10 - 2:12
    These programs are called kernels.
  • 2:12 - 2:15
    And, here's a lot of jargon in one phrase.
  • 2:15 - 2:19
    We say that the host launches kernels on the device.
タイトル:
CUDA Program Diagram - Intro to Parallel Programming
概説:

more » « less
Video Language:
English
Team:
Udacity
プロジェクト:
CS344 - Intro to Parallel Programming
Duration:
02:20

English subtitles

改訂 Compare revisions