Skip to content

Commit

Permalink
Add GPU Scan time
Browse files Browse the repository at this point in the history
  • Loading branch information
imwithye committed Jun 20, 2014
1 parent d1ad4c4 commit 47ac6ff
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 4 deletions.
4 changes: 2 additions & 2 deletions runner.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,11 @@ def red; "\033[31m#{self}\033[0m" end
result = `#{runner}`
gpu_time = /finished\s+with\s+total\s+time\s+\:\s+\d+\.\d+\s+with\s+\d+\s+iterations/.match(result) || /finished\s+with\s+total\s+time\s+\:\s+\d+\s+with\s+\d+\s+iterations/.match(result)
cpu_scan_time = /the\s+time\s+of\s+top\-\d+\s+in\s+CPU\s+version\s+is\:\d+\.\d+/.match(result) || /the\s+time\s+of\s+top\-\d+\s+in\s+CPU\s+version\s+is\:\d+/.match(result)
gpu_scan_time = ""
gpu_scan_time = /GPU\s+SCAN\s+Time\s+used\:\s+\d+.\d+/.match(result) || /GPU\s+SCAN\s+Time\s+used\:\s+\d+/.match(result)
puts "TOPK = #{arg[0]} DIMENSIONNUM = #{arg[1]} QUERYNUM = #{arg[2]}"
puts "GPU : " + gpu_time[0]
puts "CPU_SCAN: " + cpu_scan_time[0]
puts "GPU_SCAN: " + gpu_scan_time
puts "GPU_SCAN: " + gpu_scan_time[0]

puts
end
2 changes: 1 addition & 1 deletion src/Genie/Scan/CPUScan.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class CPUScan {
//cout<<"print result of Query["<<i<<"]"<<endl;
//cout<<"start ================================"<<endl;
for(int j=0;j<k;j++){
//resVec[i][j].print();//<<endl;
// resVec[i][j].print();//<<endl;
}
//cout<<"end =================================="<<endl;
}
Expand Down
23 changes: 22 additions & 1 deletion src/Genie/Scan/GPUScan.cu
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ using namespace std;

#include <thrust/device_vector.h>
#include <thrust/host_vector.h>
#include <sys/time.h>

using namespace thrust;

GPUScan::GPUScan() {
Expand Down Expand Up @@ -70,8 +72,22 @@ void GPUScan::computTopk_int_eu(vector<vector<int> >& query, int k,

convterIntToFloat(query,bladeData, query_flt, bladeData_flt);

struct timeval start;
struct timeval end;

cudaEvent_t start_t, stop_t;
float elapsedTime;
cudaEventCreate(&start_t);
cudaEventCreate(&stop_t);
cudaEventRecord(start_t, 0);

GPU_computeTopk(query_flt, query_blade_id, bladeData_flt, topk_vec, Eu_Func<float>(), topk_result_idx );

cudaEventRecord(stop_t, 0);
cudaEventSynchronize(stop_t);
cudaEventElapsedTime(&elapsedTime, start_t, stop_t);
cout << "GPU SCAN Time used: " << elapsedTime/1000 << endl;

for(int i=0;i<topk_result_idx.size();i++){
//cout<<"query item ["<<i<<"]"<<endl;
for(int j=0;j<topk_result_idx[i].size();j++){
Expand Down Expand Up @@ -110,9 +126,14 @@ void GPUScan::computTopk_int_dtw_scBand(vector<vector<int> >& query, int k,
vector<vector<float> > bladeData_flt;

convterIntToFloat(query,bladeData, query_flt, bladeData_flt);
struct timeval start;
struct timeval end;

gettimeofday(&start, NULL);
GPU_computeTopk(query_flt, query_blade_id, bladeData_flt, topk_vec, Dtw_SCBand_Func<float>(sc_band),topk_result_idx);

gettimeofday(&end, NULL);
float delta_time = (end.tv_sec* 1000000 + end.tv_usec) - (start.tv_sec * 1000000 + start.tv_usec);
cout << "GPU SCAN Time used: " << delta_time << endl;
for (int i = 0; i < topk_result_idx.size(); i++) {
cout << "query item [" << i << "]" << endl;
for (int j = 0; j < topk_result_idx[i].size(); j++) {
Expand Down

0 comments on commit 47ac6ff

Please sign in to comment.