Skip to main content
Homepage
Explore
Search or go to…
/
Sign in
Explore
Primary navigation
Project
O
OpenMP
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Collapse sidebar
Snippets
Groups
Projects
Show more breadcrumbs
Muhammad Aodyra Khaidir
OpenMP
Commits
b4ab8cfd
Commit
b4ab8cfd
authored
Feb 19, 2016
by
13513063
Browse files
Options
Downloads
Patches
Plain Diff
Program + laporan
parent
729bc0e6
No related branches found
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
laporan.txt
+78
-0
78 additions, 0 deletions
laporan.txt
omp_bucketsort
+0
-0
0 additions, 0 deletions
omp_bucketsort
omp_bucketsort.c
+88
-0
88 additions, 0 deletions
omp_bucketsort.c
with
166 additions
and
0 deletions
laporan.txt
0 → 100644
+
78
−
0
View file @
b4ab8cfd
perbandingan waktu kinerja program
1)
N = 50.000, M = 1
t = 2240 ms
N = 50.000, M = 8
t = 580 ms
N = 50.000, M = 16
t = 450 ms
N = 50.000, M = 32
t = 460 ms
N = 50.000, M = 64
t = 780 ms
N = 50.000, M = 128
t = 140 ms
2)
N = 100.000, M = 1
t = 8630 ms
N = 100.000, M = 8
t = 1440 ms
N = 100.000, M = 16
t = 1080 ms
N = 100.000, M = 32
t = 1130 ms
N = 100.000, M = 64
t = 1190 ms
N = 100.000, M = 128
t = 360 ms
3)
N = 200.000, M = 1
t = 32500 ms
N = 200.000, M = 8
t = 5160 ms
N = 200.000, M = 16
t = 3140 ms
N = 200.000, M = 32
t = 2410 ms
N = 200.000, M = 64
t = 2330 ms
N = 200.000, M = 128
t = 840 ms
4)
N = 400.000, M = 1
t = 132480 ms
N = 400.000, M = 8
t = 18430 ms
N = 400.000, M = 16
t = 10020 ms
N = 400.000, M = 32
t = 8060 ms
N = 400.000, M = 64
t = 6720 ms
N = 400.000, M = 128
t = 3450 ms
This diff is collapsed.
Click to expand it.
omp_bucketsort
0 → 100755
+
0
−
0
View file @
b4ab8cfd
File added
This diff is collapsed.
Click to expand it.
omp_bucketsort.c
0 → 100644
+
88
−
0
View file @
b4ab8cfd
#include
<stdio.h>
#include
<stdlib.h>
#include
<string.h>
#include
<time.h>
#include
<math.h>
#include
<omp.h>
#include
<assert.h>
int
*
create_rand_nums
(
int
num_elements
)
{
int
*
rand_nums
=
(
int
*
)
malloc
(
sizeof
(
int
)
*
(
num_elements
));
assert
(
rand_nums
!=
NULL
);
int
i
;
for
(
i
=
0
;
i
<
num_elements
;
i
++
)
{
rand_nums
[
i
]
=
(
abs
((
int
)
rand
())
%
num_elements
);
}
return
rand_nums
;
}
void
insertionSort
(
int
*
arr
,
int
indeksAwal
,
int
indeksAkhir
){
int
i
,
j
;
int
value
;
for
(
i
=
indeksAwal
+
1
;
i
<=
indeksAkhir
;
i
++
)
{
value
=
arr
[
i
];
j
=
i
-
1
;
while
(
j
>=
indeksAwal
&&
value
<
arr
[
j
])
{
arr
[
j
+
1
]
=
arr
[
j
];
j
=
j
-
1
;
}
arr
[
j
+
1
]
=
value
;
}
}
int
main
(
int
argc
,
char
**
argv
){
if
(
argc
!=
3
){
fprintf
(
stderr
,
"Usage: avg num_elements
\n
"
);
exit
(
1
);
}
int
i
;
srand
(
time
(
NULL
));
int
thread_count
=
atoi
(
argv
[
1
]);
int
num_elements
=
atoi
(
argv
[
2
]);
int
*
rand_nums
=
create_rand_nums
(
num_elements
);
time_t
start_t
;
start_t
=
clock
();
int
*
bucket
=
(
int
*
)
malloc
(
sizeof
(
int
)
*
num_elements
);
// bucket utama yang berisi bucket-bucket dibagi setiap elemen
int
*
indeks
=
(
int
*
)
malloc
(
sizeof
(
int
)
*
thread_count
);
// menandakan indeks awal setiap bucket pada bucket utama
int
range
=
(
num_elements
+
thread_count
)
/
thread_count
;
int
*
jumlahElemenBucket
=
NULL
;
// jumlah elemen setiap bucket
jumlahElemenBucket
=
(
int
*
)
malloc
(
sizeof
(
int
)
*
thread_count
);
memset
(
jumlahElemenBucket
,
0
,
sizeof
(
int
)
*
thread_count
);
for
(
i
=
0
;
i
<
num_elements
;
++
i
){
jumlahElemenBucket
[
rand_nums
[
i
]
/
range
]
++
;
}
for
(
i
=
0
;
i
<
thread_count
;
++
i
){
if
(
i
==
0
){
indeks
[
i
]
=
0
;
}
else
{
indeks
[
i
]
=
indeks
[
i
-
1
]
+
jumlahElemenBucket
[
i
-
1
];
}
}
memset
(
jumlahElemenBucket
,
0
,
sizeof
(
int
)
*
thread_count
);
for
(
i
=
0
;
i
<
num_elements
;
++
i
){
int
indeksBucket
=
rand_nums
[
i
]
/
range
;
bucket
[
indeks
[
indeksBucket
]
+
(
jumlahElemenBucket
[
indeksBucket
]
++
)]
=
rand_nums
[
i
];
}
#pragma omp parallel for num_threads(thread_count)
for
(
i
=
0
;
i
<
thread_count
;
++
i
){
if
(
jumlahElemenBucket
[
i
]
!=
0
){
insertionSort
(
bucket
,
indeks
[
i
],
indeks
[
i
]
+
jumlahElemenBucket
[
i
]
-
1
);
}
}
printf
(
"
\n
"
);
for
(
i
=
0
;
i
<
num_elements
;
++
i
){
printf
(
"%d
\n
"
,
bucket
[
i
]);
}
time_t
finish_t
=
clock
();
printf
(
"Waktu eksekusi %d data : %d thread : %.5f ms
\n
"
,
num_elements
,
thread_count
,
(
double
)(
finish_t
-
start_t
)
*
1000
/
CLOCKS_PER_SEC
);
free
(
rand_nums
);
free
(
bucket
);
free
(
indeks
);
free
(
jumlahElemenBucket
);
return
0
;
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
sign in
to comment