YouTube2Text

[CS61C FA20] Lecture 35.3 - Thread-Level Parallelism III: Cache Coherency — Transcript

by CS 61C Departmental · 4,095 words · 646 segments · language en · Watch on YouTube

Full transcript

  1. 0:00and welcome back now let's explore cache
  2. 0:03coherency one of the hardest
  3. 0:06parts of putting together a system that
  4. 0:09has
  5. 0:09multi-core and each core has some number
  6. 0:11of caches and the caches are either
  7. 0:13shared or not shared
  8. 0:14there's hard stuff so from the point of
  9. 0:16view of an architect we need to be
  10. 0:17thinking about
  11. 0:18how to keep the cash values coherent you
  12. 0:20saw the last i ended the last lecture
  13. 0:22with what happens when
  14. 0:23they have 20 and i want to write my 40
  15. 0:25and now the wrong value happens caches
  16. 0:27should only make things faster they
  17. 0:28should never change the value so
  18. 0:30cash is the same value that should
  19. 0:32return without caches and
  20. 0:33also same with multi-core if you do it
  21. 0:35right just adding more cores
  22. 0:37adding some parallelism shouldn't change
  23. 0:39the value just give it to you faster so
  24. 0:40again
  25. 0:40we just have the same value should come
  26. 0:42out at the end of the day just faster
  27. 0:45so here's the model when a cache so the
  28. 0:48idea is when any processor has a cache
  29. 0:49miss
  30. 0:50or right you have to notify the other
  31. 0:53processors there's a
  32. 0:54interesting way we talked about the only
  33. 0:57way you can connect with other
  34. 0:58processors
  35. 0:59other cores is through memory i can
  36. 1:01write your variable and wait for you to
  37. 1:02read it but there is a way to actually
  38. 1:04communicate with them that we're going
  39. 1:05to add and we can ask them to do things
  40. 1:08we can
  41. 1:08ask for their values in a certain block
  42. 1:10i can also ask them to invalidate a
  43. 1:12block and the way invalid blockers
  44. 1:13should make it invalid very easy
  45. 1:15so we're going to add some communication
  46. 1:17between cores to be able to actually do
  47. 1:19some of the things we're going to do
  48. 1:21so if i'm only reading in the model that
  49. 1:22we modeled before from the last lecture
  50. 1:24we're only reading
  51. 1:25we other processors can have copies we
  52. 1:26all have copies it's fine we're just
  53. 1:28reading it's just
  54. 1:28just a read-only memory finally fine on
  55. 1:30rights
  56. 1:31you can imagine we have to invalidate
  57. 1:33the other copies um
  58. 1:34and so we talked about it we that we
  59. 1:37talked about the
  60. 1:38some researchers came up with a way a
  61. 1:40protocol what they called the snoopy
  62. 1:42product protocol
  63. 1:43to think about different ways to
  64. 1:44categorize um
  65. 1:46each block in each core as one of
  66. 1:49several
  67. 1:49states and then depending on what you're
  68. 1:51doing reading and writing
  69. 1:52you change the values in those states
  70. 1:54it's a kind of interesting way to do
  71. 1:55think of that and the other cool thing
  72. 1:56is
  73. 1:56you can snoop across to ask what the
  74. 1:59values of their
  75. 1:59of their right here's a here's a here's
  76. 2:01a here's an index
  77. 2:03um here's a tag do you have the same one
  78. 2:05and if so what's your state
  79. 2:07and then do something we can have that
  80. 2:08communication and i can say please
  81. 2:10invalidate your copy if you have the
  82. 2:11same one so that's really neat
  83. 2:12and we always have to check the tags to
  84. 2:14make sure it's the same guy that's
  85. 2:15important
  86. 2:16so how do we keep them coherent each
  87. 2:19cache is going to get
  88. 2:20of each block you're going to keep track
  89. 2:21of some set of bits to keep a track of a
  90. 2:24state
  91. 2:24we're going to label these states number
  92. 2:26one shared this is like reads very easy
  93. 2:29we're all i have an up-to-date copy so
  94. 2:31this is from the point of view of each
  95. 2:33core each core has a if you're shared it
  96. 2:34means that i have an updated copy of the
  97. 2:36data
  98. 2:37and other caches may also have a copy
  99. 2:39just like the read the easy case
  100. 2:40shared everything's shared five people
  101. 2:42shared a hundred people shared oh fine
  102. 2:44modified is different modest modified
  103. 2:47says
  104. 2:47it's model from my point of view it's
  105. 2:48modified in my if my state is modified
  106. 2:50means that i have the up to date copy
  107. 2:52and my cache is update copy it's changed
  108. 2:56it's dirty and what dirty means is i'm a
  109. 2:58i'm using a right back system so the guy
  110. 3:00behind me
  111. 3:00sacramento is out of date and
  112. 3:04no other cache has a copy we don't mind
  113. 3:06this is like
  114. 3:07this is like um vanilla right back
  115. 3:09caches a right-back cache is that
  116. 3:11i have the possibility that my value is
  117. 3:13out of date with memory that's no
  118. 3:14trouble i can reads and writes i don't
  119. 3:16think a memory and only when i kick this
  120. 3:17guy out or
  121. 3:18i'm paged out or something i need to
  122. 3:20then flush that back and push it back to
  123. 3:22memory so i only go to sacramento when i
  124. 3:23need to
  125. 3:24so that's a but the key here modified is
  126. 3:26nobody else can have that
  127. 3:29okay so that's the idea this is for a
  128. 3:32bop block by block basis there are two
  129. 3:36additional perform directional states
  130. 3:38for performance optimizations
  131. 3:40we're going to add the idea of exclusive
  132. 3:43an exclusive says
  133. 3:44it's similar to modified but exclusive
  134. 3:48differs in that memory
  135. 3:49is up to date so if i'm exclusive that
  136. 3:52means that
  137. 3:52nobody has a remember modified meant
  138. 3:54nobody has a copy exclusive means nobody
  139. 3:56has a copy but in the exclusive case
  140. 3:58memory is up to date
  141. 3:59and modified it is not up to date okay
  142. 4:02so this is great i know from exclusive
  143. 4:04that means if i if the blocks replace i
  144. 4:06don't have to write to memory because i
  145. 4:07know that in a way my dirty bit is not
  146. 4:09flagged so it's a little exclusive kind
  147. 4:10of replaces the dirty bit in that sense
  148. 4:12of it
  149. 4:12um and i supplies data on a read if i'm
  150. 4:15going
  151. 4:15if i'm making it read obviously i have a
  152. 4:17copy so i can just read from that fine
  153. 4:19okay and members up to date so i don't
  154. 4:20have to kick it out if i ever kick this
  155. 4:21block out i don't need to go to memory i
  156. 4:23like exclusive as well
  157. 4:24owner owner's a little bit more
  158. 4:26complicated so we'll spend some time
  159. 4:27talking about it
  160. 4:29owner says my copy is up to date i'm the
  161. 4:31owner and what that means is
  162. 4:33other caches can have a copy but
  163. 4:37i'm the owner and they have to be in a
  164. 4:39shared state
  165. 4:40so when you have the shared state i have
  166. 4:41to be the owner so let's think about
  167. 4:43that
  168. 4:46what it means is the fun part and i'll
  169. 4:49read this to make sure there's a lot of
  170. 4:50details let me make sure i read them to
  171. 4:51make sure you understand all the pieces
  172. 4:52of this
  173. 4:53so i'm one with several with a valid
  174. 4:55copy the other copies are shared
  175. 4:57but i have the exclusive right as the
  176. 4:59owner i have the exclusive don't get
  177. 5:01this confused with the word exclusive
  178. 5:02i have the i'm the only one who has a
  179. 5:04right to make changes to it
  180. 5:07but how do i make those changes this is
  181. 5:08the fun part this is the optimization
  182. 5:10i make changes if i let's say the value
  183. 5:12is 20. we all have 20. we're all good
  184. 5:13but i'm the owner
  185. 5:14i want to make it to 40. okay
  186. 5:18one model if i use this i
  187. 5:21and by the way um
  188. 5:26memory is consistent here so we're not
  189. 5:30talking about remember being
  190. 5:30inconsistent the only so far the only
  191. 5:32remember consistent is inconsistent
  192. 5:33is in the modified state okay
  193. 5:37sorry memory might be inconsistent i'll
  194. 5:39say this again memory might be
  195. 5:40inconsistent
  196. 5:41i'm the owner i have the updated copy
  197. 5:44memory might be inconsistent
  198. 5:45okay now watch this other caches
  199. 5:49are shared and but i'm the owner i'm the
  200. 5:53one who owns really it sums up the
  201. 5:54memory spot
  202. 5:56and now if another copy
  203. 6:03if i make a change it was 20 for
  204. 6:05everybody but i'm the owner
  205. 6:07how do i make it 40. really but they're
  206. 6:10shared
  207. 6:11what i could do is i could
  208. 6:14share my 40 with the other caches
  209. 6:18so watch this i pushed it it pushed the
  210. 6:2040 to my cache now it's a 40 that's the
  211. 6:22right value
  212. 6:23and i push it to the other caches via
  213. 6:25the interconnect
  214. 6:26now they all have 40.
  215. 6:30now here's the catch what happens if
  216. 6:32there's if there's a core
  217. 6:33that never had in their cache at all and
  218. 6:35they go to read the value remember it's
  219. 6:3640 and all the people who are using it
  220. 6:38i'm the owner they're shared and they're
  221. 6:40all reading the 40 correctly
  222. 6:41and i want to go grab the current value
  223. 6:43i'm not going to go to memory first of
  224. 6:44all i'll never go to memory if i can
  225. 6:45help it
  226. 6:46it would be great if when i went to read
  227. 6:48this value i could ask the other guys do
  228. 6:50you have this block in your cache
  229. 6:53and who's the owner somebody asked guys
  230. 6:55hey folks
  231. 6:56could the owner please tell me what the
  232. 6:57value of this anybody have it
  233. 6:59so you can pass this to the other course
  234. 7:01and they
  235. 7:02say the other caches say hey i'm the my
  236. 7:05cat i'm the owner now i would say
  237. 7:06i'm the owner it is 40. and i'm
  238. 7:08basically passing
  239. 7:10the 40 to another core and never had it
  240. 7:14then they become shared and then they're
  241. 7:16fine so this is nice look at this
  242. 7:18so it says owner cash blast line says
  243. 7:22must
  244. 7:22this is this the key here owner cash
  245. 7:25lines must
  246. 7:26respond to a snoop request with data so
  247. 7:30that that's the snoopy idea
  248. 7:31i didn't have it i want to read a value
  249. 7:34it's a 40 but i don't know that
  250. 7:35my cash is empty i ask does anybody else
  251. 7:37have it and the
  252. 7:38owned cash has to respond with the 40
  253. 7:41i'd load the 40 put it in my guy i'll
  254. 7:43become another shared
  255. 7:44family okay another model is
  256. 7:49if i wanted to modify it
  257. 7:52i could i could change it to the
  258. 7:54modified state if i wanted to
  259. 7:56my cache line can be changed to the
  260. 7:57modified state member modified means
  261. 8:00modified means it's out of date but
  262. 8:03i'm nobody else has it so they're all
  263. 8:05invalid
  264. 8:06so you could hear this this line says
  265. 8:08the cache line may be changed to the
  266. 8:09modified state after invalidating
  267. 8:11all shared copies or
  268. 8:14change to the shared state by writing
  269. 8:16the modifications back to my memory
  270. 8:18so two ways to kind of get out of this
  271. 8:20if i'm the owner other people have the
  272. 8:2240 memory is wrong
  273. 8:24okay that's what we got i could either
  274. 8:27write my data all the way to memory go
  275. 8:29to sacramento write the 40. now that's
  276. 8:31consistent
  277. 8:32all the 40s have it they all had the 40s
  278. 8:34anyway that was fine and now
  279. 8:36we're all shared so i go from owner to
  280. 8:38being shared again anybody else can now
  281. 8:39grab the owner if they want to change it
  282. 8:41so i could do that
  283. 8:42i could also decide you know you had the
  284. 8:4440s but why not just inval if i
  285. 8:46invalidate you
  286. 8:47then i can now be changed to modified
  287. 8:50now modified means
  288. 8:51still inconsistent with memory i've got
  289. 8:54a 40 memory is something else
  290. 8:56but i'm modified i can invalidate them
  291. 8:58as well so there are two kind of options
  292. 9:00you can
  293. 9:00as you're thinking about how to
  294. 9:01transition there's a whole trend is a
  295. 9:03very complicated transition state
  296. 9:05diagram
  297. 9:05that talks about all these states and
  298. 9:07how you move for each of the states we
  299. 9:09don't teach n61c we teach an
  300. 9:10architecture class you learn about in
  301. 9:12other classes you'll learn
  302. 9:13but there are ways to think about how
  303. 9:14you move from owner
  304. 9:16to how do you move from owner to shared
  305. 9:18i just told you you can move forward to
  306. 9:20share by writing to main memory
  307. 9:21now the memory is consistent and now it
  308. 9:23can be part of the shared family
  309. 9:25or how to move from owner to exclusive
  310. 9:27if i wanted to
  311. 9:28by doing that i would just invalidate
  312. 9:29the other copies and now i'm the only
  313. 9:31exclusive one
  314. 9:32it's still not in main memory it's still
  315. 9:34modified not not it's inconsistent with
  316. 9:36main memory but i'm
  317. 9:37but i'm in the model not exclusive but
  318. 9:39i'm in a modified state
  319. 9:40so all those things are there
  320. 9:42complicated state transition diagram
  321. 9:44here's the picture here are all the
  322. 9:47valid
  323. 9:48pairings this is me
  324. 9:51i'm on the left i'm going to change pen
  325. 9:53real fast here
  326. 9:54i'm on the left
  327. 9:57and here's me and here's all the others
  328. 10:02others and so here's me
  329. 10:05i can be in the modified state remember
  330. 10:07the modified state
  331. 10:09and nobody else there's no other states
  332. 10:10that can be for them they have to all be
  333. 10:12invalid modified means nobody else in
  334. 10:14any other state modified means i have it
  335. 10:15everyone else
  336. 10:16doesn't have a copy at all of that block
  337. 10:17we're talking about a block on a block
  338. 10:18level
  339. 10:20or i could own it i talked about before
  340. 10:23if i own it other people could be
  341. 10:25invalid you cannot have it at all that's
  342. 10:26fine you never did anything i'm a core
  343. 10:28that's asleep
  344. 10:29fine you're invalid you don't i don't
  345. 10:30care about you your cash is empty or
  346. 10:32cold
  347. 10:33but other people could have a shared
  348. 10:34version they're all shared
  349. 10:36while i'm owned okay there's that one
  350. 10:39or i have exclusive rights and then
  351. 10:42nobody else can have it that's what
  352. 10:43exclusive means
  353. 10:44or again i can be the shared copy and
  354. 10:48somebody else is the owner
  355. 10:49or we could all just be doing reads and
  356. 10:52have a shared copy and you have a shared
  357. 10:53copy too so that's it
  358. 10:54very simple case but you can never have
  359. 10:56for example you can never have two
  360. 10:57two people this is x you can never have
  361. 10:59two exclusives you can never have two
  362. 11:01owners
  363. 11:02you can never have two modifieds this is
  364. 11:03very clean this is a very clean way of
  365. 11:05thinking about the states of the cash
  366. 11:07but in a clever way the owner is a very
  367. 11:09clever way that
  368. 11:10people could be without having to go to
  369. 11:12sacramento be reading for me very
  370. 11:14interesting
  371. 11:15to think about how did this stupid
  372. 11:16protocol where you could be poking and
  373. 11:18talking to
  374. 11:19it's almost like like sacramento's far
  375. 11:20away and like we're talking it's almost
  376. 11:21like the teachers at the front of the
  377. 11:23room and we're kind of talking to the
  378. 11:24neighbors hey
  379. 11:24did you do you want a piece of cash out
  380. 11:26here here's the value wanna go do you
  381. 11:27have it yeah let me grab it from you
  382. 11:28you're the owner i'm sure okay grab it
  383. 11:29now
  384. 11:30that the conversation's happening along
  385. 11:32in the back row
  386. 11:33as the memory is all in the front as
  387. 11:35kind of as the instructor in some way
  388. 11:37so let's actually look at one of these
  389. 11:38models so now
  390. 11:41let's go back in time now i've got two
  391. 11:42caches that have a
  392. 11:44memory location a thousand have a copy
  393. 11:46of the value 20.
  394. 11:47and i want to write a 40. it's not
  395. 11:50processor zero it's not in my cache
  396. 11:52so i check my interconnect network and i
  397. 11:55decide to
  398. 11:56invalidate the other copies i evaluate
  399. 11:59their copies
  400. 12:00and now i'm going to read the 40 i'm
  401. 12:01going to store the 40 to my cache
  402. 12:03store it in memory and we're all
  403. 12:05consistent so
  404. 12:06this is a way that we can we can make
  405. 12:08sure that we never have the problem
  406. 12:10where i wrote a 40 and you still keep
  407. 12:11your 20s but i have a 40. and so two
  408. 12:13blocks are very
  409. 12:14you'll never have that case um where two
  410. 12:17blocks
  411. 12:18don't have the same value ever um if i'm
  412. 12:20going to do a right to a 40 i'm going to
  413. 12:22either invalidate them
  414. 12:23or grab owner and pass my 40 to them and
  415. 12:26update them for 40 but you're never
  416. 12:27going to have
  417. 12:28a kind of a resting photograph of the
  418. 12:29state where this guy thinks it's 1040
  419. 12:32and this one thinks it's a thousand
  420. 12:33twenty never going to happen
  421. 12:35either i'm writing a 40 and i invalidate
  422. 12:37everybody else and nobody else has it
  423. 12:38and they just had copies anyway that's
  424. 12:39fine caches are just copies they were
  425. 12:41just read only copies not write
  426. 12:42writ written copies not out of sync they
  427. 12:44were synced with memory that's fine
  428. 12:46or i have a 40 and i'm going to pass the
  429. 12:4940 to other people over there we can
  430. 12:51still
  431. 12:51whether memory is inconsistent or
  432. 12:52consistent is all there but the owner's
  433. 12:54job
  434. 12:54is it to finally connect with memory if
  435. 12:56it gets kicked out make sure to write
  436. 12:57that 40 eventually memory that's the
  437. 12:59part that's interesting here
  438. 13:00really fun and really interesting if you
  439. 13:02if you dig deeper into
  440. 13:03what the the snoopy uh state state
  441. 13:06diagram is and how you move from state
  442. 13:08to state kind of fun
  443. 13:10now let's bring up a really big issue
  444. 13:11and this is something that we're gonna
  445. 13:12we're gonna see
  446. 13:13often as we have more and more cores
  447. 13:15dealing with really big blocks
  448. 13:18so what's the problem here looks this
  449. 13:20looks fine i've got a block size of 32
  450. 13:22bytes no problem
  451. 13:23i've got cross two processor two caches
  452. 13:26and you can maybe already see there's an
  453. 13:28issue here
  454. 13:29processor zero is reading and writing
  455. 13:30variable x that happens to live
  456. 13:32at address four thousand processor y is
  457. 13:36reading writing variable y
  458. 13:37that happens to live at address forty
  459. 13:41twelve
  460. 13:43well x is it four thousand why is it
  461. 13:46forty 12
  462. 13:47these are independent these are totally
  463. 13:48independent i'm really writing here
  464. 13:50you're reading writing there
  465. 13:51well what's going to happen can you can
  466. 13:53you already see what's going to happen
  467. 13:55well that block is going to ping-pong
  468. 13:58between those two caches as
  469. 13:59each one thinks they're accessing the
  470. 14:02same
  471. 14:02information and you want to make sure we
  472. 14:04don't have those issues and so
  473. 14:05only one person is going to own it even
  474. 14:07though in theory you could build a
  475. 14:09system
  476. 14:09that both of them could write to just an
  477. 14:11area of it but because you only checked
  478. 14:12at the block level
  479. 14:14you can't have that it'll just ping pong
  480. 14:16in and out in and out in and out
  481. 14:17from the two areas and and each one
  482. 14:19thinks that i have it no you have it no
  483. 14:20i haven't now you have it
  484. 14:22and this is a problem so how do you
  485. 14:24prevent it how do we let's see
  486. 14:25how do we prevent it well one way to
  487. 14:27already pause the video and think about
  488. 14:28it well one way to reduce the
  489. 14:31possibility of is i have smaller block
  490. 14:32sizes
  491. 14:33the larger the block size the more the
  492. 14:34chance of i'm going to be writing to
  493. 14:36areas of the array and multiple areas of
  494. 14:37the processor might do that
  495. 14:39you could also think from the
  496. 14:40programming standpoint if you knew the
  497. 14:41size of the block
  498. 14:42you could make sure that you never if
  499. 14:45you did this really well
  500. 14:46that you never have a processor um
  501. 14:50share any space at all on the same block
  502. 14:53line as anybody else just make sure that
  503. 14:54you own this part of memory and i'm down
  504. 14:56here and you're done there and you're
  505. 14:57down there and you have that issue as
  506. 14:58well
  507. 14:58um so let's think about how to resolve
  508. 15:01this let's think about
  509. 15:02let's see let's this is our review three
  510. 15:05c's these were the three kind of misses
  511. 15:07you had with caches you have a
  512. 15:08compulsory miss
  513. 15:09these are a cold start miss you've got a
  514. 15:11block never seen before
  515. 15:12everyone has to do first access to the
  516. 15:14block you got to take this the solution
  517. 15:15for a cold start miss
  518. 15:17is for compulsory misses you increase
  519. 15:19the block size
  520. 15:20um certainly have more penalty to go to
  521. 15:22sacramento but when you're there
  522. 15:23now you're loading in more of it and now
  523. 15:25you have less of memory
  524. 15:27the larger the block size less of memory
  525. 15:29has to take
  526. 15:30to kind of from a block point of view
  527. 15:32have to take that hit i grabbed it and i
  528. 15:34grabbed a huge block that's great
  529. 15:36and while i was the second i loaded now
  530. 15:38all of those guys don't have to have
  531. 15:39compulsory misses because they're loaded
  532. 15:41in
  533. 15:41so that's nice capacity misses
  534. 15:44which means not compulsory but at
  535. 15:46capacity capacity miss well
  536. 15:48i can't i can't if i only if i only had
  537. 15:52a larger cache
  538. 15:53i wouldn't have that capacity we'll make
  539. 15:54the cash larger solutions make the cash
  540. 15:56larger
  541. 15:56okay or a conflict miss we saw that so
  542. 15:59not compulsory or capacity but a
  543. 16:01conflict miss
  544. 16:02the solution is well think about more
  545. 16:04associativity
  546. 16:05don't have a direct map or 2a make it
  547. 16:07four-way or make it fully associative
  548. 16:08think about that so either increase the
  549. 16:10cache size increase the sensitivity or
  550. 16:13incl
  551. 16:13work on the replacement policy maybe
  552. 16:15look at the workload you're having
  553. 16:17be smarter about your replacement policy
  554. 16:20the fourth c this is the fourth c
  555. 16:22it's called a coherence miss it means
  556. 16:25within one block two different
  557. 16:28cores think that they have that these
  558. 16:31variables that may be distinct
  559. 16:33are actually shared and so now you're
  560. 16:35going to have them loaded in and out
  561. 16:37as we saw before i have to invalidate
  562. 16:39the other copies because i'm making a
  563. 16:41reading to write to this and have to
  564. 16:42evaluate the other copies but no way the
  565. 16:43other guy isn't actually modifying that
  566. 16:45verb i modified this part in the block
  567. 16:46i'm modifying here your modifying there
  568. 16:48sorry the rules say that if i own this
  569. 16:51block
  570. 16:51nobody else can have it so that we don't
  571. 16:53have the wrong copy so i have to
  572. 16:54invalidate your copies and so you end up
  573. 16:56having these things ping pong here
  574. 16:57so this is also known as a communication
  575. 16:59myth we don't this is really hard it's
  576. 17:01really really hard
  577. 17:02and in some sense coherence misses can
  578. 17:04dominate total misses overall with
  579. 17:05parallel programs that's really
  580. 17:07interesting
  581. 17:07you had these three c's you thought that
  582. 17:08was the world i'm telling you there's a
  583. 17:09fourth c and i'm telling you not only
  584. 17:11that that the fourth c actually can be
  585. 17:13the biggest
  586. 17:13problem the biggest number of misses in
  587. 17:15this case
  588. 17:17all done last slide on thread level
  589. 17:19parallelism
  590. 17:21in conclusion openmp is a beautiful
  591. 17:23parallel extension to see there okay all
  592. 17:25right
  593. 17:25let's step back even farther and this is
  594. 17:27off off script
  595. 17:28you don't have to program in c you can
  596. 17:30program a lot of other languages that
  597. 17:31may be easier or harder or
  598. 17:33more useful for your particular problem
  599. 17:35if you're living in c
  600. 17:36though openmp is a great solution to be
  601. 17:38able to bring parallelism to your c
  602. 17:40code you've got these pragmas you've got
  603. 17:42private variables reductions parallel
  604. 17:44four parallel fours this will get you a
  605. 17:45long way so play with that
  606. 17:47we know this is easy to learn but not
  607. 17:48high level so you can get you into
  608. 17:50trouble
  609. 17:51thread level parallelism one of the
  610. 17:52issues as you're building a system for
  611. 17:54it as you're one of the now the
  612. 17:55architects below the hardware line
  613. 17:57is dealing with cache coherency coming
  614. 17:59up with protocols ways you can have it
  615. 18:01and mention it there's a state diagram
  616. 18:02where you label every block with these
  617. 18:04tags and
  618. 18:04think about that that you want to reduce
  619. 18:06this that you want to first of all make
  620. 18:08sure that your system always works
  621. 18:09so cache coherency first at the base
  622. 18:11level make sure that your cache doesn't
  623. 18:13give the wrong value
  624. 18:14that's part of the hard part of this and
  625. 18:16false sharing is a concern
  626. 18:17the larger a block size this sharing
  627. 18:20these two variables these two areas of
  628. 18:22memory are not being shared
  629. 18:24across these two processors that trust
  630. 18:26these two cores there's two threads
  631. 18:27working on these two cores
  632. 18:28but in fact there is a false sharing
  633. 18:31that says nope sorry
  634. 18:32it's the same block it must be the same
  635. 18:33one no it's not they're at different
  636. 18:34areas sorry
  637. 18:35we're not really the hard way to solve
  638. 18:36that so that's a problem and that causes
  639. 18:38these coherence misses
  640. 18:40that's it watch out for the block size
  641. 18:42for there we're done we're done with
  642. 18:43thread level parallelism
  643. 18:44we will see you next lecture where we
  644. 18:46talk about drum roll piece
  645. 18:49warehouse scale computing and map
  646. 18:51produce we'll see you there

About this transcript

This page contains the full transcript of [CS61C FA20] Lecture 35.3 - Thread-Level Parallelism III: Cache Coherency by CS 61C Departmental, generated from the public captions YouTube serves with the video. The transcript has 4,095 words across 646 segments, with the original timestamps preserved so you can click any line to jump to that moment in the embedded player.

What you can do with it

Use the transcript to take notes, quote the speaker, build a study guide, generate a summary with ChatGPT or Claude via the YouTube Summary tool, or export it as a timed subtitle file with YouTube to SRT. You can also re-open it in the transcriber to translate the transcript into 100+ languages.

Free YouTube transcript tool

YouTube2Text is a free YouTube transcript generator — no signup, no daily limit. Paste any YouTube link and get the full transcript instantly, with timestamps, click-to-jump, translation to 100+ languages, AI prompts for ChatGPT, Claude, and Gemini, and exports to TXT, SRT, VTT, or Markdown.