Changes

Jump to: navigation, search

K2

2,322 bytes added, 05:34, 1 April 2018
Assignment1
'''Analysis and Profiling'''
<source>
void bitonicSort(int* array, int N){
int i,j,k;
for (k=2;k<=N;k=2*k) {
for (j=k>>1;j>0;j=j>>1) {
for (i=0;i<N;i++) {
int ixj=i^j;
if ((ixj)>i) {
if ((i&k)==0 && array[i]>array[ixj]){
int temp=array[i];
array[i]=array[ixj];
array[ixj]=temp;
}
if ((i&k)!=0 && array[i]<array[ixj]){
int temp=array[i];
array[i]=array[ixj];
array[ixj]=temp;
}
}
}
}
}
}
</source>
'''Flat profile'''
The number of elements in array:2^15(32768)
<source>
Each sample counts as 0.01 seconds.
% cumulative self self total
time seconds seconds calls ms/call ms/call name
100.00 0.02 0.02 1 20.00 20.00 bitonicSort(int*, int)
0.00 0.02 0.00 1 0.00 0.00 _GLOBAL__sub_I__Z11bitonicSortPii
0.00 0.02 0.00 1 0.00 0.00 generateRandom(int*, int)
0.00 0.02 0.00 1 0.00 0.00 __static_initialization_and_destruction_0(int, int)
</source>
 
The number of elements in array:2^20(1048576)
<source>
Each sample counts as 0.01 seconds.
% cumulative self self total
time seconds seconds calls s/call s/call name
98.95 1.89 1.89 1 1.89 1.89 bitonicSort(int*, int)
1.05 1.91 0.02 1 0.02 0.02 generateRandom(int*, int)
0.00 1.91 0.00 1 0.00 0.00 _GLOBAL__sub_I__Z11bitonicSortPii
0.00 1.91 0.00 1 0.00 0.00 __static_initialization_and_destruction_0(int, int)
</source>
 
The number of elements in array:2^25(33554432)
<source>
Each sample counts as 0.01 seconds.
% cumulative self self total
time seconds seconds calls s/call s/call name
99.46 91.66 91.66 1 91.66 91.66 bitonicSort(int*, int)
0.54 92.16 0.50 1 0.50 0.50 generateRandom(int*, int)
0.00 92.16 0.00 1 0.00 0.00 _GLOBAL__sub_I__Z11bitonicSortPii
0.00 92.16 0.00 1 0.00 0.00 __static_initialization_and_destruction_0(int, int)
</source>
58
edits

Navigation menu