首页
网站开发
桌面应用
管理软件
微信开发
App开发
嵌入式软件
工具软件
数据采集与分析
其他
首页
>
> 详细
辅导Web开发|解析C/C++编程|辅导留学生 Statistics统计、回归、迭代|讲解留学生Processing
项目预算:
开发周期:
发布时间:
要求地区:
Assignment 6: Multi-threaded Map Reduce in Rust
Assignment 6: Multi-threaded Map Reduce in Rust
Due Sunday by 11:59pm
Points 50
Submitting a file upload
Available after May 23 at 8am
Start Assignment
Introduction
In this assignment, you'll write a program that will get you familiar with writing multi-threaded programs in Rust.
Learning Outcomes
Write simple programs in Rust (Module 9, MLO 2)
Compile, debug, manage and run Rust programs (Module 9, MLO 3)
Explain the facility for threads provided by Rust (Module 10, MLO 2)
Map Reduce
According to the Wikipedia article on MapReduce
MapReduce is a programming model and an associated implementation for processing and generating big data sets with a
parallel, distributed algorithm on a cluster.
A MapReduce program is composed of a map procedure, which performs filtering and sorting (such as sorting students by first
name into queues, one queue for each name), and a reduce method, which performs a summary operation (such as counting the
number of students in each queue, yielding name frequencies).
Instructions
For this assignment, we are providing you with a single-threaded Rust program
processes input numbers to produce a sum. The program contains extensive comments that explain the functionality and give directions
on what parts of code you are allowed to change (look for comments starting with CHANGE CODE).
Assignment 6: Multi-threaded Map Reduce in Rust
Here is a description of the program: currently the main() function does the following
Generates data for the rest of the program
Calls generate_data() to generates a vector of numbers that serves as input for the rest of the program.
Partitions the data
Calls partition_data_in_two() which partitions the input numbers into two partitions
Performs the map step
Calls map_data() for each of the two partitions, which returns the sum of all the numbers in that partition.
Performs the reduce step
Gathers the intermediate results produced by each call to map_data()
Calls reduce_data() that sums up the intermediate results produced by the map step to produce the final sum of all the input
numbers.
You have to modify the program to accomplish the following tasks:
Modify the program to create 2 threads, each of which concurrently runs the map_data() function on one of the two partitions
created by the program given to you.
Add code for the function partition_data() to partition the data into equal-sized partitions based on the argument num_partitions
In case num_elements is not a multiple of num_partitions, some partitions can have one more element than other partitions
Add code to the function main() to
Partition the data into equal-size partitions
Create as many threads as the number of partitions and have each thread concurrently run the map_data() function to process
one partition each
Gather the intermediate results returned by each thread
Run the reduce step to process the intermediate results and produce the final result
See detailed comments in the provided program to see how you can go about making the required changes.
Example Usage
Here are some example executions of the program.
An execution of the program with 5 partitions and 150 elements.
Assignment 6: Multi-threaded Map Reduce in Rust
Since the number of elements is a multiple of the number of partitions, it is required that each partition should have the same
number of elements.
However, there is no requirement about which element is put into which partition. Thus the intermediate sums in your solution can be
different from what is shown below.
./main 5 150
Number of partitions = 2
size of partition 0 = 75
size of partition 1 = 75
Intermediate sums = [2775, 8400]
Sum = 11175
Number of partitions = 5
size of partition 0 = 30
size of partition 1 = 30
size of partition 2 = 30
size of partition 3 = 30
size of partition 4 = 30
Intermediate sums = [435, 1335, 2235, 3135, 4035]
Sum = 11175
An execution of the program with 6 partitions and 150 elements.
./main 6 150
Number of partitions = 2
size of partition 0 = 75
size of partition 1 = 75
Intermediate sums = [2775, 8400]
Sum = 11175
Number of partitions = 6
size of partition 0 = 25
size of partition 1 = 25
size of partition 2 = 25
size of partition 3 = 25
size of partition 4 = 25
size of partition 5 = 25
Intermediate sums = [300, 925, 1550, 2175, 2800, 3425]
Sum = 11175
An execution of the program with 5 partitions and 153 elements.
In this example the number of elements is not a multiple of the number of partitions.
Based on the requirement that some partitions can have one element more than other partitions, in this case 3 partitions must have
31 elements and 2 partitions must have 30 elements.
Assignment 6: Multi-threaded Map Reduce in Rust
In the example shown below, the 3 partitions with 31 elements are at position 0, 1 and 2 in the vector of partitions, and the 2
partitions with 30 elements are at position 3 and 4 in that vector. However, there is no requirement about the order in which partitions
that have one more element than other partitions appear in the vector of partitions. Thus, the order of the partitions in your solution
can be different from what is shown below.
./main 5 153
Number of partitions = 2
size of partition 0 = 76
size of partition 1 = 77
Intermediate sums = [2850, 8778]
Sum = 11628
Number of partitions = 5
size of partition 0 = 31
size of partition 1 = 31
size of partition 2 = 31
size of partition 3 = 30
size of partition 4 = 30
Intermediate sums = [585, 1486, 2387, 3135, 4035]
Sum = 11628
Hints
The function thread::spawn()
returns JoinHandle
where T is the type of the
return value of the function the thread runs. This means that
Because map_data() returns an integer of type usize
If you spawn a thread that runs map_data()
thread::spawn() will return a value of type JoinHandle
What to turn in?
Required: Upload one file main.rs with all of your code.
When you resubmit a file in Canvas, Canvas can attach a suffix to the file, e.g., the file name may become main-1.rs . Don't
worry about this name change as no points will be deducted because of this.
Optional: If you have any meta-comments about the program, create a file README.txt with these comments, and upload it with
your submission as a separate file (i.e., don't zip up the two files together).
Grading Criteria
Assignment 6: Multi-threaded Map Reduce in Rust
5/5
Total Points: 50
Assignment 6 Rust
Criteria
Ratings
This assignment is worth 8% of your final grade. The breakup of points is given in the grading rubric.
The grading will be done on os1.
To test your program, we will compile the code as follows
rustc main.rs
We will run the program as follows
./main num_partitions num_elements
E.g.,
./main 5 150
This criterion is linked to a Learning OutcomeProcesses the two partitions in the provided program by creating two threads
each of which concurrently runs map_data() on one partition each.
partition_data() partitions the data into num_partitions and the sizes of the partitions are correct.
Implements map-reduce using as many concurrent threads as the number of partitions in the argument.
请加QQ:99515681 或邮箱:99515681@qq.com WX:codehelp
软件开发、广告设计客服
QQ:99515681
邮箱:99515681@qq.com
工作时间:8:00-23:00
微信:codinghelp
热点项目
更多
代做ceng0013 design of a pro...
2024-11-13
代做mech4880 refrigeration a...
2024-11-13
代做mcd1350: media studies a...
2024-11-13
代写fint b338f (autumn 2024)...
2024-11-13
代做engd3000 design of tunab...
2024-11-13
代做n1611 financial economet...
2024-11-13
代做econ 2331: economic and ...
2024-11-13
代做cs770/870 assignment 8代...
2024-11-13
代写amath 481/581 autumn qua...
2024-11-13
代做ccc8013 the process of s...
2024-11-13
代写csit040 – modern comput...
2024-11-13
代写econ 2070: introduc2on t...
2024-11-13
代写cct260, project 2 person...
2024-11-13
热点标签
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
联系我们
- QQ: 9951568
© 2021
www.rj363.com
软件定制开发网!