Computer Science > QUESTIONS & ANSWERS > University of California, BerkeleyCS 61C61chw10. (All)
Q1 Parallelism Principles 7 Points The Hamming distance between two bitstrings of equal length is the number of locations in which the bits differ. For example, hamming(0b1011101, 0b1001001) == 2 ... . Consider the following Hamming distance code: uint32_t hamming(uint32_t x, uint32_t y) { uint32_t mask, ham_dist = 0; #pragma omp for for (int i = 0; i <= 31; i++) { mask = 1 << i; if ((y & mask) != (x & mask)) { ham_dist++; } } return ham_dist; } Q1.1 Shared/Private Variables 4 Points For each variable below, decide whether it SHOULD be "shared" or "private" among threads. Do not mark a variable as private if it can be safely shared. x y mask shared private shared private9/11/2020 View Submission | Gradescope https://www.gradescope.com/courses/92697/assignments/512318/submissions/40847486 2/24 i Q 1.2 Data Race 2 Points Is a data race on ham_dist possible? Make sure you can explain why or why not. If yes, think about how to fix the code. Based on your answer above, which variables could be incorrect as a result of the data race? Q1.3 False Sharing 1 Point shared private shared private Yes No x y m ask i h am_dist None of the above. There was no data race. [Show More]
Last updated: 1 year ago
Preview 1 out of 24 pages
Connected school, study & course
About the document
Uploaded On
Apr 25, 2021
Number of pages
24
Written in
This document has been written for:
Uploaded
Apr 25, 2021
Downloads
0
Views
45
In Browsegrades, a student can earn by offering help to other student. Students can help other students with materials by upploading their notes and earn money.
We're available through e-mail, Twitter, Facebook, and live chat.
FAQ
Questions? Leave a message!
Copyright © Browsegrades · High quality services·