Efficient Movie Rental Strategies for Improved Business Operations

excercises n.w
1 / 79
Embed
Share

In this scenario, the challenge is to reduce the time taken for movie rentals from a vast warehouse. The suggested improvements include keeping popular movies in the front office, anticipating customer preferences, and organizing movies in series for quicker access. Analogous to cache locality concepts, recognizing spatial and temporal patterns in movie rentals can enhance efficiency. This strategy optimizes resource utilization and improves customer satisfaction.

  • Movie rentals
  • Warehouse management
  • Efficiency improvement
  • Cache locality
  • Business optimization

Uploaded on | 0 Views


Download Presentation

Please find below an Image/Link to download the presentation.

The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author. If you encounter any issues during the download, it is possible that the publisher has removed the file from their server.

You are allowed to download the files provided on this website for personal or commercial use, subject to the condition that they are used lawfully. All files are the property of their respective owners.

The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author.

E N D

Presentation Transcript


  1. Excercises Lesson 2016

  2. Question 1 You have a huge warehouse with EVERY movie ever made (hits, training films, etc.). Getting a movie from the warehouse takes 15 minutes. You can t stay in business if every rental takes 15 minutes. You have some small shelves in the front office. Office Warehouse

  3. Here are some suggested improvements to the store: 1. Whenever someone rents a movie, just keep it in the front office for a while in case someone else wants to rent it. 2. Watch the trends in movie watching and attempt to guess movies that will be rented soon put those in the front office. 3. Whenever someone rents a movie in a series (Star Wars), grab the other movies in the series and put them in the front office. 4. Buy motorcycles to ride in the warehouse to get the movies faster Extending the analogy to locality for caches, which pair of changes most closely matches the analogous cache locality? Office Selection Spatial Temporal A 2 1 B 4 2 Warehouse C 4 3 D 3 1 E None of the above

  4. Question 1 Principle of Locality Program instructions access a small proportion of their address space at any time

  5. Question 1 Principle of Locality Program instructions access a small proportion of their address space at any time Customers Individual movie Movie collection

  6. Question 1 Principle of Locality Program instructions access a small proportion of their address space at any time Customers Individual movie Movie collection Temporal locality Items accessed recently are likely to be accessed again soon

  7. Question 1 Principle of Locality Program instructions access a small proportion of their address space at any time Customers Individual movie Movie collection Temporal locality Items accessed recently are likely to be accessed again soon Spatial locality Items near those accessed recently are likely to be accessed soon

  8. Question 1 Principle of Locality Program instructions access a small proportion of their address space at any time Customers Individual movie Movie collection Temporal locality Items accessed recently are likely to be accessed again soon Spatial locality Items near those accessed recently are likely to be accessed soon ? ?

  9. Question 1 Principle of Locality Program instructions access a small proportion of their address space at any time Customers Individual movie Movie collection Temporal locality Items accessed recently are likely to be accessed again soon Spatial locality Items near those accessed recently are likely to be accessed soon

  10. Question 1 Principle of Locality Program instructions access a small proportion of their address space at any time Customers Individual movie Movie collection Temporal locality Items accessed recently are likely to be accessed again soon Spatial locality Items near those accessed recently are likely to be accessed soon Let s go back to our question

  11. Here are some suggested improvements to the store: 1. Whenever someone rents a movie, just keep it in the front office for a while in case someone else wants to rent it. 2. Watch the trends in movie watching and attempt to guess movies that will be rented soon put those in the front office. 3. Whenever someone rents a movie in a series (Star Wars), grab the other movies in the series and put them in the front office. 4. Buy motorcycles to ride in the warehouse to get the movies faster Extending the analogy to locality for caches, which pair of changes most closely matches the analogous cache locality? Office Selection Spatial Temporal A 2 1 B 4 2 Warehouse C 4 3 D 3 1 E None of the above

  12. Here are some suggested improvements to the store: 1. Whenever someone rents a movie, just keep it in the front office for a while in case someone else wants to rent it. 2. Watch the trends in movie watching and attempt to guess movies that will be rented soon put those in the front office. 3. Whenever someone rents a movie in a series (Star Wars), grab the other movies in the series and put them in the front office. 4. Buy motorcycles to ride in the warehouse to get the movies faster Extending the analogy to locality for caches, which pair of changes most closely matches the analogous cache locality? Office Selection Spatial Temporal A 2 1 B 4 2 Warehouse C 4 3 D 3 1 E None of the above

  13. Question 2 For the following code, identify the variables that contribute to temporal locality and the variables that contribute to spatial locality. The variables are i, j, and the array A. for (i = 0; i < 3; i++) for (j = 0; j < 3; j++) A [ i ] [ j ] = 5 + A [ j ] [ i ];

  14. Question 2 A is a matrix (two dimensional array) j = 2 j = 0 j = 1 for (i = 0; i < 3; i++) for (j = 0; j < 3; j++) A [ i ] [ j ] = 5 + A [ j ] [ i ]; i = 0 i = 1 i = 2

  15. Question 2 A is a matrix (two dimensional array) How is A stored in the memory? j = 2 j = 0 j = 1 i = 0 address i = 1 i = 2 Memory

  16. Question 2 A is a matrix (two dimensional array) A[0,0] How is A stored in the memory? j = 2 j = 0 j = 1 i = 0 address i = 1 i = 2 Memory

  17. Question 2 A is a matrix (two dimensional array) A[0,0] A[0,1] How is A stored in the memory? j = 2 j = 0 j = 1 i = 0 address i = 1 i = 2 Memory

  18. Question 2 A is a matrix (two dimensional array) A[0,0] A[0,1] How is A stored in the memory? A[0,2] j = 2 j = 0 j = 1 i = 0 address i = 1 i = 2 Memory

  19. Question 2 A is a matrix (two dimensional array) A[0,0] A[0,1] How is A stored in the memory? A[0,2] A[1,0] j = 2 j = 0 j = 1 i = 0 address i = 1 i = 2 Memory

  20. Question 2 A is a matrix (two dimensional array) A[0,0] A[0,1] How is A stored in the memory? A[0,2] A[1,0] A[1,1] j = 2 j = 0 j = 1 i = 0 address i = 1 i = 2 Memory

  21. Question 2 A is a matrix (two dimensional array) A[0,0] A[0,1] How is A stored in the memory? A[0,2] A[1,0] A[1,1] A[1,2] j = 2 j = 0 j = 1 i = 0 address i = 1 A[2,0] i = 2 A[2,1] A[2,2] Memory

  22. Question 2 for (i = 0; i < 3; i++) for (j = 0; j < 3; j++) A [ i ] [ j ] = 5 + A [ j ] [ i ]; A[0,0] A[0,1] A[0,2] A[1,0] A[1,1] A[1,2] j = 2 j = 0 j = 1 i = 0 i = 1 A[2,0] i = 2 A[2,1] A[2,2] In each iteration, we access two array slots A[i][j] and A[j][i]

  23. Question 2 A[i][j] accesses A[j][i] accesses for (i = 0; i < 3; i++) for (j = 0; j < 3; j++) A [ i ] [ j ] = 5 + A [ j ] [ i ]; A[0,0] A[0,1] A[0,2] A[1,0] A[1,1] A[1,2] j = 2 j = 0 j = 1 i = 0 i = 1 A[2,0] i = 2 A[2,1] A[2,2] In each iteration, we access two array slots A[i][j] and A[j][i] Iteration 1: i = 0, j = 0

  24. Question 2 A[i][j] accesses A[j][i] accesses for (i = 0; i < 3; i++) for (j = 0; j < 3; j++) A [ i ] [ j ] = 5 + A [ j ] [ i ]; A[0,0] A[0,1] * A[0,2] A[1,0] A[1,1] A[1,2] j = 2 j = 0 j = 1 i = 0 i = 1 A[2,0] i = 2 A[2,1] A[2,2] In each iteration, we access two array slots A[i][j] and A[j][i] Iteration 1: i = 0, j = 0

  25. Question 2 A[i][j] accesses A[j][i] accesses for (i = 0; i < 3; i++) for (j = 0; j < 3; j++) A [ i ] [ j ] = 5 + A [ j ] [ i ]; A[0,0] A[0,1] * * A[0,2] A[1,0] A[1,1] A[1,2] j = 2 j = 0 j = 1 i = 0 i = 1 A[2,0] i = 2 A[2,1] A[2,2] In each iteration, we access two array slots A[i][j] and A[j][i] Iteration 1: i = 0, j = 0

  26. Question 2 A[i][j] accesses A[j][i] accesses for (i = 0; i < 4; i++) for (j = 0; j < 3; j++) A [ i ] [ j ] = 5 + A [ j ] [ i ]; A[0,0] A[0,1] * * A[0,2] A[1,0] A[1,1] A[1,2] j = 2 j = 0 j = 1 i = 0 i = 1 A[2,0] i = 2 A[2,1] A[2,2] In each iteration, we access two array slots A[i][j] and A[j][i] Iteration 2: i = 0, j = 1

  27. Question 2 A[i][j] accesses A[j][i] accesses for (i = 0; i < 4; i++) for (j = 0; j < 3; j++) A [ i ] [ j ] = 5 + A [ j ] [ i ]; A[0,0] A[0,1] * * * A[0,2] A[1,0] A[1,1] A[1,2] j = 2 j = 0 j = 1 i = 0 i = 1 A[2,0] i = 2 A[2,1] A[2,2] In each iteration, we access two array slots A[i][j] and A[j][i] Iteration 2: i = 0, j = 1

  28. Question 2 A[i][j] accesses A[j][i] accesses for (i = 0; i < 4; i++) for (j = 0; j < 3; j++) A [ i ] [ j ] = 5 + A [ j ] [ i ]; A[0,0] A[0,1] * * * A[0,2] A[1,0] A[1,1] A[1,2] * j = 2 j = 0 j = 1 i = 0 i = 1 A[2,0] i = 2 A[2,1] A[2,2] In each iteration, we access two array slots A[i][j] and A[j][i] Iteration 2: i = 0, j = 1

  29. Question 2 A[i][j] accesses A[j][i] accesses for (i = 0; i < 4; i++) for (j = 0; j < 3; j++) A [ i ] [ j ] = 5 + A [ j ] [ i ]; A[0,0] A[0,1] * * * A[0,2] A[1,0] A[1,1] A[1,2] * j = 2 j = 0 j = 1 i = 0 i = 1 A[2,0] i = 2 A[2,1] A[2,2] In each iteration, we access two array slots A[i][j] and A[j][i] Iteration 3: i = 0, j = 2

  30. Question 2 A[i][j] accesses A[j][i] accesses for (i = 0; i < 4; i++) for (j = 0; j < 3; j++) A [ i ] [ j ] = 5 + A [ j ] [ i ]; A[0,0] A[0,1] * * * * A[0,2] A[1,0] A[1,1] A[1,2] * j = 2 j = 0 j = 1 i = 0 i = 1 A[2,0] i = 2 A[2,1] A[2,2] In each iteration, we access two array slots A[i][j] and A[j][i] Iteration 3: i = 0, j = 2

  31. Question 2 A[i][j] accesses A[j][i] accesses for (i = 0; i < 4; i++) for (j = 0; j < 3; j++) A [ i ] [ j ] = 5 + A [ j ] [ i ]; A[0,0] A[0,1] * * * * A[0,2] A[1,0] A[1,1] A[1,2] * j = 2 j = 0 j = 1 i = 0 i = 1 A[2,0] * i = 2 A[2,1] A[2,2] In each iteration, we access two array slots A[i][j] and A[j][i] Iteration 3: i = 0, j = 2

  32. Question 2 A[i][j] accesses A[j][i] accesses for (i = 0; i < 4; i++) for (j = 0; j < 3; j++) A [ i ] [ j ] = 5 + A [ j ] [ i ]; A[0,0] A[0,1] * * * * A[0,2] A[1,0] A[1,1] A[1,2] * j = 2 j = 0 j = 1 i = 0 i = 1 A[2,0] * i = 2 A[2,1] A[2,2] In each iteration, we access two array slots A[i][j] and A[j][i] Iteration 4: i = 1, j = 0

  33. Question 2 A[i][j] accesses A[j][i] accesses for (i = 0; i < 4; i++) for (j = 0; j < 3; j++) A [ i ] [ j ] = 5 + A [ j ] [ i ]; A[0,0] A[0,1] * * * * * A[0,2] A[1,0] A[1,1] A[1,2] * j = 2 j = 0 j = 1 i = 0 i = 1 A[2,0] * i = 2 A[2,1] A[2,2] In each iteration, we access two array slots A[i][j] and A[j][i] Iteration 4: i = 1, j = 0

  34. Question 2 A[i][j] accesses A[j][i] accesses for (i = 0; i < 4; i++) for (j = 0; j < 3; j++) A [ i ] [ j ] = 5 + A [ j ] [ i ]; A[0,0] A[0,1] * * * * * * A[0,2] A[1,0] A[1,1] A[1,2] * j = 2 j = 0 j = 1 i = 0 i = 1 A[2,0] * i = 2 A[2,1] A[2,2] In each iteration, we access two array slots A[i][j] and A[j][i] Iteration 4: i = 1, j = 0

  35. Question 2 A[i][j] accesses A[j][i] accesses for (i = 0; i < 4; i++) for (j = 0; j < 3; j++) A [ i ] [ j ] = 5 + A [ j ] [ i ]; A[0,0] A[0,1] * * * * * * * A[0,2] A[1,0] A[1,1] A[1,2] * j = 2 j = 0 j = 1 * i = 0 i = 1 A[2,0] * i = 2 A[2,1] A[2,2] In each iteration, we access two array slots A[i][j] and A[j][i] Iteration 5: i = 1, j = 1

  36. Question 2 A[i][j] accesses A[j][i] accesses for (i = 0; i < 4; i++) for (j = 0; j < 3; j++) A [ i ] [ j ] = 5 + A [ j ] [ i ]; A[0,0] A[0,1] * * * * * * * * A[0,2] A[1,0] A[1,1] A[1,2] * j = 2 j = 0 j = 1 * i = 0 i = 1 A[2,0] * i = 2 A[2,1] * A[2,2] In each iteration, we access two array slots A[i][j] and A[j][i] Iteration 6: i = 1, j = 2

  37. Question 2 A[i][j] accesses A[j][i] accesses for (i = 0; i < 4; i++) for (j = 0; j < 3; j++) A [ i ] [ j ] = 5 + A [ j ] [ i ]; A[0,0] A[0,1] * * * * * * * * * A[0,2] A[1,0] A[1,1] A[1,2] * j = 2 j = 0 j = 1 * i = 0 * i = 1 A[2,0] * * * i = 2 A[2,1] * * * A[2,2] In each iteration, we access two array slots A[i][j] and A[j][i] Iteration 9: i = 3, j = 3

  38. Question 2 A[i][j] accesses A[j][i] accesses for (i = 0; i < 4; i++) for (j = 0; j < 3; j++) A [ i ] [ j ] = 5 + A [ j ] [ i ]; A[0,0] A[0,1] * * * * * * * * * A[0,2] A[1,0] A[1,1] A[1,2] * j = 2 j = 0 j = 1 * Irregular access Regular access i = 0 * i = 1 A[2,0] * * * i = 2 A[2,1] * * * A[2,2] In each iteration, we access two array slots A[i][j] and A[j][i] Iteration 9: i = 3, j = 3

  39. Question 2 A[i][j] accesses A[j][i] accesses for (i = 0; i < 4; i++) for (j = 0; j < 3; j++) A [ i ] [ j ] = 5 + A [ j ] [ i ]; A[0,0] A[0,1] * * * * * * * * * A[0,2] A[1,0] A[1,1] A[1,2] * j = 2 j = 0 j = 1 * Irregular access Regular access i = 0 * i = 1 A[2,0] * * * i = 2 A[2,1] * * * A[2,2] In each iteration, we access two array slots A[i][j] and A[j][i] Accessing A[i][j] exhibits spatial locality Accessing A[j][i] doesn t exhibit spatial locality Iteration 9: i = 3, j = 3

  40. Question 2 A[i][j] accesses A[j][i] accesses for (i = 0; i < 4; i++) for (j = 0; j < 3; j++) A [ i ] [ j ] = 5 + A [ j ] [ i ]; A[0,0] A[0,1] * * * * * * * * * A[0,2] A[1,0] A[1,1] A[1,2] * j = 2 j = 0 j = 1 * Irregular access Regular access i = 0 * i = 1 A[2,0] * * * i = 2 A[2,1] * * * A[2,2] What about i and j? Accessing A[i][j] exhibits spatial locality Accessing A[j][i] doesn t exhibit spatial locality

  41. Question 2 A[i][j] accesses A[j][i] accesses for (i = 0; i < 4; i++) for (j = 0; j < 3; j++) A [ i ] [ j ] = 5 + A [ j ] [ i ]; A[0,0] A[0,1] * * * * * * * * * A[0,2] A[1,0] A[1,1] A[1,2] * j = 2 j = 0 j = 1 * Irregular access Regular access i = 0 * i = 1 A[2,0] * * * i = 2 A[2,1] * * * A[2,2] What about i and j? They exhibit temporal locality because they are accessed in each iteration Accessing A[i][j] exhibits spatial locality Accessing A[j][i] doesn t exhibit spatial locality

  42. Question 3 Direct Mapped Cache Assume that we have a direct mapped cache. Our cache has 4 blocks. Each block holds one word. Each word in memory maps to exactly one cache location. Then for the following memory addresses, which column (A, B, C or D) correctly shows the cache misses and hits? index tag data 00 Access time 01 10 11 Cache structure

  43. Question 3 Let s have a brief review over direct mapped cache Taken from lecture slides

  44. Question 3 Taken from lecture slides

  45. Question 3 First note that our cache has only 4 blocks. This means that if we want to put any memory block in the cache, it must be put in one of these 4 blocks. index tag data 00 01 10 11 Cache structure

  46. Question 3 First note that our cache has only 4 blocks. This means that if we want to put any memory block in the cache, it must be put in one of these 4 blocks. Question: how many memory blocks can we address using 8 bits? Assume that each block is four bytes long (one word). index tag data 00 01 10 11 Cache structure

  47. Question 3 First note that our cache has only 4 blocks. This means that if we want to put any memory block in the cache, it must be put in one of these 4 blocks. Question: how many memory blocks can we address using 8 bits? Assume that each block is four bytes long (one word). Answer: 28 / 4 = 64 blocks index tag data 00 01 10 11 Cache structure

  48. Question 3 First note that our cache has only 4 blocks. This means that if we want to put any memory block in the cache, it must be put in one of these 4 blocks. Question: how many memory blocks can we address using 8 bits? Assume that each block is four bytes long (one word). Answer: 28 / 4 = 64 blocks Our cache has only 4 blocks. Also, note that each memory block can be mapped to only one cache block. index tag data 00 01 10 11 Cache structure

  49. Question 3 First note that our cache has only 4 blocks. This means that if we want to put any memory block in the cache, it must be put in one of these 4 blocks. Question: how many memory blocks can we address using 8 bits? Assume that each block is four bytes long (one word). Answer: 28 / 4 = 64 blocks Our cache has only 4 blocks. Also, note that each memory block can be mapped to only one cache block. index tag data 00 01 Question: how many memory blocks are mapped to the same cache block? 10 11 Cache structure

  50. Question 3 First note that our cache has only 4 blocks. This means that if we want to put any memory block in the cache, it must be put in one of these 4 blocks. Question: how many memory blocks can we address using 8 bits? Assume that each block is four bytes long (one word). Answer: 28 / 4 = 64 blocks Our cache has only 4 blocks. Also, note that each memory block can be mapped to only one cache block. index tag data 00 01 Question: how many memory blocks are mapped to the same cache block? 10 11 Answer: 64 / 4 = 16 blocks Cache structure

Related


More Related Content