代做CS-350 - Fundamentals of Computing Systems Homework Assignment #7 - BUILD代做R语言

CS-350 - Fundamentals of Computing Systems

Homework Assignment #7 - BUILD

Due on November 7, 2024 — Late deadline: November 9, 2024 EoD at 11:59 pm

BUILD Problem 1

Now that we have a nice running image server, we will now look to understand how our code interact with key system resources, in particular the CPU, the Level-1 Cache (L1 Cache), and the Last-Level Cache (LLC). In order to do this we will leverage the Unix “perf” infrastructure.  The perf subsystem gives us access to several hardware counters in our machine, allowing us to profile instruction counts and memory behavior. such as cache hits/misses.  As we have seen in class, CPU-bound operations will spend most of their time on the CPU, without requiring additional resource.  Operations that require access to a lot of data, on the other hand, will demand more service from the memory subsystem.  Whenever a process needs data, L1 cache lookup is performed. If the data is not in L1, an LLC lookup is performed. A miss in LLC means that an access in main memory (DRAM) needs to be performed.

Output File: server_img_perf .c

Overview. Once again, we are not going to scrap everything we have build together so far. On the contrary, we are building on top of it once again. This time around, we have provided you with a new library called perflib (see files perflib .c and perflib.h). With this assignment, we will enable profiling of operations in our image processing server!

First, the type of operations from the client are the same as before, and the same goes for the structure of the client-originated requests and expected responses. Your goal is to use the provided perflib to sample the various hardware performance counters and determine how many hardware  events  are caused by an image operation carried out by the server.

So what are hardware events anyway? As your code executes, it completes assembly instructions. The completion of a CPU instruction is an example of one such events. Say that while executing an instruction, data is looked up into the L1 Cache and not found (L1 cache miss), that’s another type of event. The same goes for a lookup that causes a miss in LLC. Thus, as you execute any code, one can count the number of events of diferent type caused by your code. And “perf” can be used precisely for this.

Design. Please take a look at the code of the new perflib library.  The library provides useful helper functions to interact with “perf” and sample the various hardware counters of interest.

For this assignment, once again, we will ask you to implement single-threaded implementation of the image server. The main diference is that every image processing operation carried out by the server will be profiled to understand the number of hardware  events  generated by the corresponding code.  For each run of the server, we will focus on a specific type of event among three events of interest:

1. Number of completed CPU instructions;

2. Number of L1 cache misses;

3. Number of LLC cache misses.

To do so, first, the server should accept an additional flag as one of the input parameters, namely -h. This ag will be used to specify what type of hardware event we wish to count when the server is launched from the command line.  The -h parameter must be followed by a string:  (1) “INSTR”, (2) “L1MISS”, or (3) “LLCMISS” .

In your server, once you detect the argument of the -h parameter, you should pass this information to your worker thread which will use the provided perlib functions to setup and sample hardware event counters.

The provided perflib provides two main operations: (1) setup_perf_counter( . . .) and (2) read_perf_counter( . . .).

First, the int  setup_perf_counter(uint64_t  type,  uint64_t  config)  function allows you to setup event counting for the calling thread.  If event setup is successful, it returns an integer that can be con- sidered as a handle  (actually, a file descriptor) to access the counters. Say we call this handle evt_fd. The function takes two parameters to specify the event to be monitored via its type and config.

When we are setting up our performance counter, the type parameter and config parameter must be set in correspondence with the event we intend to monitor.

1. Instruction: type  =  PERF_TYPE_HARDWARE and config  =  PERF_COUNT_HW_INSTRUCTIONS.

2. L1 cache misses: type  =  PERF_TYPE_HW_CACHE and

config  =   (PERF_COUNT_HW_CACHE_L1D)   |    (PERF_COUNT_HW_CACHE_OP_READ   << 8)

|    (PERF_COUNT_HW_CACHE_RESULT_MISS  << 16)

3. LLC cache misses: type  =  PERF_TYPE_HW_CACHE and

config  =   (PERF_COUNT_HW_CACHE_LL)   |    (PERF_COUNT_HW_CACHE_OP_READ   << 8)

|    (PERF_COUNT_HW_CACHE_RESULT_MISS  << 16)

You can read https://man7.org/linux/man-pages/man2/perf_event_open.2.html to find out about all the diferent types of hardware counters and how to configure perflib to count diferent events!

Once the counters have been setup, you can enable counting with the system call: ioctl(evt_fd,  PERF_EVENT_IOC_ENABLE,  0).

You can also reset the current value of the counters with using: ioctl(evt_fd,  PERF_EVENT_IOC_RESET,  0).

Most importantly, you can always read the current value of the counter you have setup for observation with the provided uint64_t  read_perf_counter(int  evt_fd) function. This function takes in input the aforementioned handle evt_fd and returns the current value of the number of sampled hardware events since the last counter reset.

To recap, (1) extend the main to recognize the new -h paremeter; (2) perform. the setup of the event under consideration, according to what has been passed using the -h parameter. This needs to be done during the initialization of the same (!)  thread that will sample the hardware events.  Next, (3) every time an image operation is performed by the worker thread, sample how many hardware events (of the appropriate type) are caused by said operation.  Finally, (4) print out the sampled number of hardware events together with the other statistics about the completed operation—see output format below.

Desired Output. The output that should be produced everytime animage processing request is completed matches for the most part the format we have seen in HW6. Specifically, at every request completion, your server must output something of the form.

T  R:,,,,,,,,

Here, is a string representing the requested operation over an image. For instance, if the operation was IMG_REGISTER, then the server should output the string “IMG REGISTER” (no quotes) for this field.  should just be 0 or 1, depending on what the client requested.   should be the image ID for which the client has requested an operation.

If the server is ignoring any of these values in the response, set these elds to 0. Finally,  should report the image ID on which the server has performed the operation requested by the client. Recall that this might be diferent from what sent by the client if overwrite  =  0 in the client’s request, but it must be the same if overwrite  =  1.

Next,  must be the same string as what was passed to the server with the -h parameter—thus “INSTR”,  “L1MISS”, or  “LLCMISS” . Finally,  must be the sampled number of hardware events of the considered type occured while processing the request with ID .  NOTE: these last two fields must be omitted ONLY in the case of an IMG_REGISTER operation.

Submission Instructions: in order to submit the code produced as part of the solution for this homework assignment, please follow the instructions below.

You should submit your solution in the form. of C source code.   To  submit your code,  place all the  .c and  .h files inside  a  compressed  folder  named  hw7.zip.   Make  sure  they  compile  and  run  correctly  ac- cording  to  the  provided  instructions.   The rst  round  of grading  will  be  done  by  running  your  code. Use CodeBuddy to submit the entire hw7.zip archive at https://cs-people.bu.edu/rmancuso/courses/ cs350-fa23/codebuddy.php?hw=hw7. You can submit your homework multiple times until the deadline. Only your most recently updated version will be graded.  You will be given instructions on Piazza on how to interpret the feedback on the correctness of your code before the deadline.





热门主题

课程名

mktg2509 csci 2600 38170 lng302 csse3010 phas3226 77938 arch1162 engn4536/engn6536 acx5903 comp151101 phl245 cse12 comp9312 stat3016/6016 phas0038 comp2140 6qqmb312 xjco3011 rest0005 ematm0051 5qqmn219 lubs5062m eee8155 cege0100 eap033 artd1109 mat246 etc3430 ecmm462 mis102 inft6800 ddes9903 comp6521 comp9517 comp3331/9331 comp4337 comp6008 comp9414 bu.231.790.81 man00150m csb352h math1041 eengm4100 isys1002 08 6057cem mktg3504 mthm036 mtrx1701 mth3241 eeee3086 cmp-7038b cmp-7000a ints4010 econ2151 infs5710 fins5516 fin3309 fins5510 gsoe9340 math2007 math2036 soee5010 mark3088 infs3605 elec9714 comp2271 ma214 comp2211 infs3604 600426 sit254 acct3091 bbt405 msin0116 com107/com113 mark5826 sit120 comp9021 eco2101 eeen40700 cs253 ece3114 ecmm447 chns3000 math377 itd102 comp9444 comp(2041|9044) econ0060 econ7230 mgt001371 ecs-323 cs6250 mgdi60012 mdia2012 comm221001 comm5000 ma1008 engl642 econ241 com333 math367 mis201 nbs-7041x meek16104 econ2003 comm1190 mbas902 comp-1027 dpst1091 comp7315 eppd1033 m06 ee3025 msci231 bb113/bbs1063 fc709 comp3425 comp9417 econ42915 cb9101 math1102e chme0017 fc307 mkt60104 5522usst litr1-uc6201.200 ee1102 cosc2803 math39512 omp9727 int2067/int5051 bsb151 mgt253 fc021 babs2202 mis2002s phya21 18-213 cege0012 mdia1002 math38032 mech5125 07 cisc102 mgx3110 cs240 11175 fin3020s eco3420 ictten622 comp9727 cpt111 de114102d mgm320h5s bafi1019 math21112 efim20036 mn-3503 fins5568 110.807 bcpm000028 info6030 bma0092 bcpm0054 math20212 ce335 cs365 cenv6141 ftec5580 math2010 ec3450 comm1170 ecmt1010 csci-ua.0480-003 econ12-200 ib3960 ectb60h3f cs247—assignment tk3163 ics3u ib3j80 comp20008 comp9334 eppd1063 acct2343 cct109 isys1055/3412 math350-real math2014 eec180 stat141b econ2101 msinm014/msing014/msing014b fit2004 comp643 bu1002 cm2030
联系我们
EMail: 99515681@qq.com
QQ: 99515681
留学生作业帮-留学生的知心伴侣!
工作时间:08:00-21:00
python代写
微信客服:codinghelp
站长地图