代做COMS 6998 High Performance Machine Learning Homework Assignment 1 Fall 2024代写Python语言

COMS 6998 - High Performance Machine Learning

Homework Assignment 1

Fall 2024

Due Date: September 29 2024

Use the Google Cloud platform. (GCP) or your own machine. Make sure that your Google VM or your machine has at last 32GB of RAM to be able to complete the assignments. GCP coupons will be shared with you.

Instructions:

Theoretical questions are identified by Q<number> while coding exercises are identified by C<number>. Submit a tar-archive named with your Columbia UNI (e.g. <UNI>.tar) that unpacks to

- /dp1.c

- /dp2.c

- /dp3.c

- /dp4.py

- /dp5.py

- /results.pdf

The pdf contains the outputs of the programs and the answers to the questions.

C1                                                                                              20 points

Write a micro-benchmark that investigates the performance of computing the dot-product that takes two arrays of ’float’ (32 bit) as input. The dimension of the vector space and the number of repetitions for the measurement are command line arguments, i.e. a call ’./dp1 1000 10’ performs 10 measurements on a dot product with vectors of size 1000.

Initialize fields in the input vectors to 1.0.

float dp(long N, float *pA, float *pB) {

float R = 0.0;

int j;

for (j=0;j<N;j++)

R += pA[j]*pB[j];

return R;

}

Name the program dp1.c and compile with gcc -O3 -Wall -o dp1 dp1.c .

Make sure the code is executed on a platform. that has enough RAM. The 300000000 size runs should not be killed by the system!

Measure the execution time of the function with clock gettime(CLOCK MONOTONIC).

Measure the time for N=1000000 and N=300000000. Perform. 1000 repetitions for the small case and 20 repetitions for the large case. Compute the appropriate mean for the execution time for the second half of the repetitions.

For the average times, compute the bandwidth in GB/sec and throughput in FLOP/sec, and print the result as

N: 1000000 <T>: 9.999999 sec B: 9.999 GB/sec F: 9.999 FLOP/sec

N: 300000000 <T>: 9.999999 sec B: 9.999 GB/sec F: 9.999 FLOP/sec

C2                                                                                         15 points

Perform. the same microbenchmark with

float dpunroll(long N, float *pA, float *pB) {

float R = 0.0;

int j;

for (j=0;j<N;j+=4)

R += pA[j]*pB[j] + pA[j+1]*pB[j+1] \

+ pA[j+2]*pB[j+2] + pA[j+3] * pB[j+3];

return R;

}

C3                                                                                       15 points

Perform. the same microbenchmark with MKL (Intel library), you may need to install a ’module’ to access MKL.

#include <mkl_cblas.h>

float bdp(long N, float *pA, float *pB) {

float R = cblas_sdot(N, pA, 1, pB, 1);

return R;

}

C4                                                                                    10 points

Implement the same microbenchmark in python, using numpy arrays as input.

A = np.ones(N,dtype=np.float32)

B = np.ones(N,dtype=np.float32)

# for a simple loop

def dp(N,A,B):

R = 0.0;

for j in range(0,N):

R += A[j]*B[j]

return R

C5                                                                                    10 points

Perform. the same measurements using ’numpy.dot’.

Q1                                                                                   5 points

Explain the rationale and expected consequence of only using the second half of the measurements for the computation of the mean execution time. Moreover, explain what type of mean is appropriate for the calculations, and why.

Q2                                                                                    15 points

Draw a roofline model based on a peak performance of 200 GFLOPS and memory band-width of 30 GB/s. Add a vertical line for the arithmetic intensity. Plot points for the 10 measurements for the average results for each microbenchmark. The roofline model must be ”plotted” using matplotlib or an equivalent package.

Based on your plotted measurements, explain clearly whether the computations are com-pute or memory bound, and why. Discuss the underlying reasons for why these compu-tations differ or don’t across each microbenchmark.

Lastly, identify any microbenchmarks that underperform. relative to the roofline, and explain the algorithmic bottlenecks responsible for this performance gap.

Q3                                                                                       5 points

Using the N = 300000000 simple loop as the baseline, explain the the difference in per-formance for the 5 measurements in the C and Python variants. Explain why this occurs by considering the underlying algorithms used.

Q4                                                                                     5 points

Check the result of the dot product computations against the analytically calculated result. Explain your findings, and why the results occur. (Hint: Floating point operations are not exact.)

COMS 6998 - High Performance Machine Learning

Cloud and MKL Setup Instructions

Parijat Dube and Kaoutar El Maghraoui

1 Google Cloud Setup

This setup assumes that you have a functional Google Cloud account and have used the credits provided by the course to create a billing account. You should also have a project linked to the billing account in which you can create VM instances. Refer the follow-ing link on how to create a project with a billing account Creating Managing Projects.

1. Go to the following link: cloud.google.com and click on Console on the top right of the page.

2. Click on Create a VM option.

Make sure that you have the project with the billing account for the course selected.

3. Configure the VM with the required hardware

There are two things that need to be done for the first homework. This is first changing the machine configuration to a machine with higher RAM. In the above screenshot, you can see I have selected a machine with 32 GB RAM.

The second thing that needs to be done is to increase the storage space of the virtual machine from 10GB to at least 30GB. In the above screenshot, you can see I have increased the storage space to 50GB to be on the safer side.

Once you have configured your machine, scroll to the bottom of the page and click on the Create button to create an instance.

4. Go to the dashboard to check out the created VM instance

5. SSH into the created VM instance

2 Intel MKL Library Installation

For this installation, we will be using the Intel OneAPI Basekit. The instructions for installation are given in the following link: Installation using APT manager. There are other options for installation as well, but we suggest following the APT manager installation.

Make sure you have installed wget.

sudo apt install wget

1. Download the key to system key ring

Copy and paste the following command into the SSH terminal of the VM instance:

wget -O-

https://apt.repos.intel.com/intel-gpg-keys/GPG-PUB-KEY-INTEL-SW-PRODUCTS.PUB

| gpg --dearmor | sudo tee /usr/share/keyrings/oneapi-archive-keyring.gpg

> /dev/null

The above command is a single line. Make sure there are no new lines in the command.

2. Add signed entry to apt sources and configure the APT client to use Intel repository

echo "deb [signed-by=/usr/share/keyrings/oneapi-archive-keyring.gpg]

https://apt.repos.intel.com/oneapi all main" |

sudo tee /etc/apt/sources.list.d/oneAPI.list

The above command is also a single line. Make sure there are no new lines in the command.

3. Update packages list and repository index

sudo apt update

4. Install MKL basekit

sudo apt install intel-basekit

This is going to take a while to install.

5. Set environment variables

. /opt/intel/oneapi/setvars.sh

Now you are all set to run your code with the MKL library.

3 Running Code with MKL Linkage

This section assumes that you have a functioning code for C3. The commands given below are single line commands and need to be run with any new lines. Make sure to remove new lines before running the commands in the terminal.

Option 1: Using MKL_LINK_TOOL

/opt/intel/oneapi/mkl/2022.2.0/bin/intel64/mkl_link_tool

gcc -O3 -Wall -o dp3 dp3.c

Option 2: Using GCC Flags

gcc -O3 -Wall -o dp3

-I /opt/intel/oneapi/mkl/2022.2.0/include dp3.c

-L /opt/intel/oneapi/mkl/2022.2.0/lib -lmkl_rt




热门主题

课程名

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
站长地图