Return to Video

The Need For Barriers - Quiz - Intro to Parallel Programming

  • 0:00 - 0:02
    Here's an example of the need for barriers.
  • 0:02 - 0:06
    Say we've got an array in memory with a bunch of elements: 1, 2, 3, 4, 5, 6,
  • 0:06 - 0:09
    and we want to shift each of these left by 1.
  • 0:09 - 0:12
    In other words, we want this element go here,
  • 0:12 - 0:15
    this element go here, this element go here and so on.
  • 0:15 - 0:18
    So here's a little code snippet that should do this.
  • 0:18 - 0:22
    We first initialize the elements of array to the thread index,
  • 0:22 - 0:26
    and you'll see that I've hardcoded of this to 128 just to be lazy.
  • 0:26 - 0:31
    So every thread is going to set its corresponding array element to its own index.
  • 0:31 - 0:35
    So this should initialize things to 1, 2, 3, 4, 5, 6 and so on.
  • 0:35 - 0:39
    And then avoiding stepping off the end of the array with this if statement,
  • 0:39 - 0:43
    every thread will set its corresponding array element
  • 0:43 - 0:50
    at its index equal to the value of the array element at the thread's index plus 1.
  • 0:50 - 0:54
    So thread 1 will set its value to whatever is written in array sub 2.
  • 0:54 - 0:59
    Thread 2 will set array sub 2 equal to whatever is in array sub 3 and so forth.
  • 0:59 - 1:05
    So here's a quick quiz: How many barriers does this code need?
Title:
The Need For Barriers - Quiz - Intro to Parallel Programming
Description:

more » « less
Video Language:
English
Team:
Udacity
Project:
CS344 - Intro to Parallel Programming
Duration:
01:03
Udacity Robot edited English subtitles for 03-30 The Need For Barriers - Quiz
Udacity Robot edited English subtitles for 03-30 The Need For Barriers - Quiz
Stacy Taylor approved English subtitles for 03-30 The Need For Barriers - Quiz
Lauren Birdsong edited English subtitles for 03-30 The Need For Barriers - Quiz
Cogi-Admin added a translation

English subtitles

Revisions Compare revisions