关键词 > Python代写

DASK HOMEWORK

发布时间:2021-09-30

Hello, dear friend, you can consult us at any time if you have any questions, add WeChat: daixieit


DASK HOMEWORK (HW 1)


1. Instructions

1.1. What to look at. The only references you may use for this lab are:

● The dask website for api reference

● Any material on Canvas

In particular, do not use stackoverflow or chegg for two reasons: (1) it will result in an academic integrity violation and (2) you are likely to get a hilariously incorrect answer from them.


1.2. How to collaborate.

● Write down (in your code) the names of people you collaborate with.

● You cannot look at code/pseudocode written by other students.

● You cannot copy/email/transmit code. Your code must be typed by you without looking at other people’s code.

● You can discuss algorithmic strategies (pictures are fine, pseudocode is not)


1.3. Getting the code and submitting the code. Run updatestarter. To submit your code, commit and push it to github, then submit to the gradescope hw1 assignment (tell gradescope to pull the code from your github repository).

        Make sure to only commit python code, and no other files into your repository.


1.4. The Assignment. The homework consists of 3 files:

● hw1.py: This is where you will write your code (you can add functions if you want)

● driver.py: This file helps test your code (type python driver.py in the command line to run it)

● hwfunctions.py: This file contains functions your code needs to use.

        The goal of this assignment is to create parallel versions of the following functions:

        Your parallel versions must be significantly faster than the serial versions (your goal is to use the ideas taught in class to see how much faster you can make it). After your parallel versions have been added to hw1.py, you can type python driver.py. This will run your parallel code and compare it to the serial code (it will compare answers and speed).


Question 1 (20 points). In hw1.py, fill in the function delayed_increment(c, start, end). This function must use dask delayed to create a parallel version of serial_inc. The first parameter c is the client, so you do not need to create one yourself. The return value of the function must be a dask delayed objectnot the result of the computation (the code in driver.py will take the computation graph defined by your delayed object and run it to get the answer). Your function must make use of the fun_inc function defined in hwfunctions.py.


Question 2 (20 points). In hw1.py, fill in the function delayed_factor(c, start, end). This function must use dask delayed to create a parallel version of serial_factor. The first parameter c is the client, so you do not need to create one yourself. The return value of the function must be a dask delayed objectnot the result of the computation (the code in driver.py will take the computation graph defined by your delayed object and run it to get the answer). Your function must make use of the fun_factor function defined in hwfunctions.py.


Question 3 (20 points). In hw1.py, fill in the function future_increment(c, start, end). This function must use the futures api to create a parallel version of serial_inc (this is like question 1, but using futures instead of delayed). The first parameter c is the client, so you do not need to create one yourself. The return value of the function must be a futures object, not the result of the computation (the code in driver.py will obtain the answer from the futures object). Do not use delayed api in this function. Your function must make use of the fun_inc function defined in hwfunctions.py.


Question 4 (20 points). In hw1.py, fill in the function future_factor(c, start, end). This function must use the futures api to create a parallel version of serial_factor. The first parameter c is the client, so you do not need to create one yourself. The return value of the function must be a futures object, not the result of the computation (the code in driver.py will obtain the answer from the futures object). Do not use delayed api in this function. Your function must make use of the fun_factor function defined in hwfunctions.py.