首页
网站开发
桌面应用
管理软件
微信开发
App开发
嵌入式软件
工具软件
数据采集与分析
其他
首页
>
> 详细
program编程讲解、辅导C++语言、C++程序设计调试 辅导Web开发|辅导Database
项目预算:
开发周期:
发布时间:
要求地区:
Develop a C++ program that applies a parallel hash table
Design and implement a hash table with separate chaining and linear probing
Apply parallel programming concepts with the use of OpenMP
II. Prerequisites:
Before starting this programming assignment, participants should be able to:
Apply and implement class templates
Design, implement, and test medium programs in C++
Edit, build, debug, and run programs through a Linux environment
Describe the operations of a hash table
Describe the purpose of parallel programming
Identify parallel tasks
III. Overview & Requirements:
What is required?
For this project, you will implement functions for TWO hash table implementations.
Initially your implementations for both hash tables will be run in serial. A second version
of the “ProbingHash will be required, in which you add some parallel programming
constructs. You are being tasked with implementing both a separate chaining and a linear
probing hash table. The starting code base includes abstract class called “Hash”, which
the two concrete classes “ChainingHash” and “ProbingHash” are derived from. Please start
with the code. The file Hash.h includes a description of the interface and what you need to
implement with it.
The interface mostly follows the std::unordered_map interface, but it has been limited
a bit to avoid iterators and some of the more complex return type behaviors. The Hash.h
file has the actual interfaces, but here is the summary:
// Hash class interface notes
// ******************PUBLIC OPERATIONS*********************
// bool empty( ) --> Test for empty hash
// int size( ) --> Quantity of (non-deleted) elements in hash
// V& at( const K& k ) --> Returns the value with key k
// V& operator[]( const K& k ) --> Returns the value with key k
// int count( const K& key ) --> Returns the number of elements with key k
// bool emplace ( const K& key, V& value ) --> Adds element with key, true if successful
// bool insert( const pair
& pair ) --> Adds pair to hash, true if successful
// void erase( const K& k ) --> Removes all any (if any) entries with key k
// void clear( ) --> Empties the hash
// int bucket_count() --> Returns the number of buckets allocated (size
of the hash vector)
// int bucket_size( int n ) --> Returns the number of elements in bucket n (0,
1, or length of list if chaining)
// int bucket( const K& key ) --> Returns the bucket number of key (or throws
std::out_of_range if key not found)
// float load_factor( ) --> Returns the load factor of the hash
// void rehash( int n ) --> Resizes the hash to contain at least n buckets
// Resizes to next prime starting from n and
going up
Serial Implementation (50 pts – 25 pts/implementation)
In this part of the assignment, you will add features to the provided code for both types of
hash tables. Your initial solutions will be designed as usual, with a serial model. There are
notes in both .h files (“ChainingHash.h” and “ProbingHash.h”) about where you need to fill
in the stubbed functions or replace/update the ones that are there. Those public
interfaces cannot be changed, but you could add more public and private variables or
methods as you see fit.
Separate Chaining: This is a hash table where the data is stored in a vector of lists. Feel
free to use the C++ STL std::vector and std::list classes. You will also need to keep
track of the total number of elements stored in the hash for calculating “size.” Rehashing
is performed at a load factor of 0.75.
Linear Probing: This is a hash table with a single vector of elements, but it MUST do lazy
deletion. This means that every element in the table needs to be a std::pair (or some
other approach, I suppose). The pair needs to keep track if the bucket is empty, full, or
deleted and your code must use that information when probing and rehashing. You’ll need
to keep track of the total size of the hash table (total ‘full’, but not deleted buckets). This
is doing linear probing when probe(i’) = i. Rehashing is performed at a load factor of 0.75.
Both hash tables are only expected to work with integer keys, but it is templated all the
same. If you have got some time, please feel free to add some string key handling, but it
is not required.
Once you have finished your serial implementation, in main(), create an object of type
ChainingHash and one of type ProbingHash. Set the initial sizes of the tables to 101.
In order, insert values with keys 1 – 1,000,000. For simplicity, the key and value stored are
the same. For both tables, separately report the total amount of time, in seconds,
required to insert the values. Write the results to a file called “HashAnalysis.txt”. Search
for the value with key 177 in both tables. Report the time required to find the value in
each table by writing it to the file. Search for the value with key 2,000,000 in both tables.
Report the time required to find the value in each table by writing it to the file. Remove
the value with key 177 from both tables. Report the time required to remove the value
with in each table by writing it to the file. Also, write to the file the final size, bucket
count, and load factor of the hash for both implementations. Make sure that the results in
the file are clearly identifiable.
Parallel Implementation (20 pts)
Copy the contents of the “ProbingHash.h” file and place the copy in another file called
“ParallelProbingHash.h”. Rename the class in this file to ParallelProbingHash. Be sure
to include
. Add OpenMP code to your implementation in the new file.
Specifically, add critical regions (#pragma omp critical) around the appropriate code
that performs insertions, deletions, and rehashing. Recall, within a critical region, only
one thread at a time can execute that code. This is one technique for mutual exclusion
that OpenMP supports.
In main(), create an object of type ParallelProbingHash. Set the initial size of the
table to 101.
Using one thread:
Set the number of threads (omp_set_num_threads()) to 1 initially. In an OpenMP
parallel region (#pragma omp parallel), in order, insert values with keys 1 –
1,000,000. Inside the parallel region make sure that the value for the iteration number of
the loop is shared among all threads. For simplicity, the key and value stored are the
same. Report the total amount of time, in seconds, required to insert the values to the
output file. Search for the value with key 177. Report the time required to find the value
by writing it to the file. Search for the value with key 2,000,000. Report the time required
to find the value by writing it to the file. Remove the value with key 177. Report the time
required to remove the value by writing it to the file. Make sure that the results in the file
are clearly identifiable.
Using the number of threads that matches number of cores on your system:
Change the number of threads to match the number of cores on your system. In an
OpenMP parallel region (#pragma omp parallel), in order, insert values with keys 1 –
1,000,000. Inside the parallel region make sure that the value for the iteration number of
the loop is shared among all threads. For simplicity, the key and value stored are the
same. Report the total amount of time, in seconds, required to insert the values to the
output file. Search for the value with key 177. Report the time required to find the value
by writing it to the file. Search for the value with key 2,000,000. Report the time required
to find the value by writing it to the file. Remove the value with key 177. Report the time
required to remove the value by writing it to the file. Make sure that the results in the file
are clearly identifiable.
Other Requirements (20 pts):
- In a comment block at the top of your main.cpp file, you must
address the following questions:
(6 pts) How did the serial implementations for the
ChainingHash and ProbingHash compare to each other? Did you
expect the time results obtained? Explain.
(8 pts) Compare the parallel and serial implementations for
the ProbingHash. Did the parallel implementations provide you
with the expected speedup? Explain.
(8 pts) What could you change in your parallel
implementations to improve performance and speedup? Explain.
Makefile Requirement (5 pts):
You are required to implement a Makefile for this assignment. Please make sure that you
add flags –g -Wall –std=c++11 -fopenmp when building. The -fopenmp is critical for the
OpenMP code!!!
IV. Submitting Assignments:
1. You must submit all required .h/.hpp, .cpp, .txt files and the Makefile.
2. Your project must build properly. The most points an assignment can receive if it
does not build properly is 65 out of 100.
V. Grading Guidelines:
This assignment is worth 100 points. Your assignment will be evaluated based on a
successful compilation and adherence to the program requirements. We will grade
according to the following criteria:
95 pts for adhering to requirements listed above – see each requirement for
point totals
5 pts for appropriate class and top-down design and adherence to proper
programming style established for the class and comments
软件开发、广告设计客服
QQ:99515681
邮箱:99515681@qq.com
工作时间:8:00-23:00
微信:codinghelp
热点项目
更多
代写math 1151, autumn 2024 w...
2024-11-14
代做comp4336/9336 mobile dat...
2024-11-14
代做eesa01 lab 2: weather an...
2024-11-14
代写comp1521 - 24t3 assignme...
2024-11-14
代写nbs8020 - dissertation s...
2024-11-14
代做fin b377f technical anal...
2024-11-14
代做ceic6714 mini design pro...
2024-11-14
代做introduction to computer...
2024-11-14
代做cs 353, fall 2024 introd...
2024-11-14
代做phy254 problem set #3 fa...
2024-11-14
代写n1569 financial risk man...
2024-11-14
代写csci-ua.0202 lab 3: enco...
2024-11-14
代写econ2226: chinese econom...
2024-11-14
热点标签
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
软件定制开发网!