Mercurial > hg > Game > Cerium
changeset 2039:892c77a1529f draft
Add flip option to fft example
author | Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Thu, 12 Feb 2015 17:04:03 +0900 |
parents | a78f8360c7f9 |
children | bc010492ade4 363b7c401c79 |
files | example/fft/main.cc |
diffstat | 1 files changed, 11 insertions(+), 8 deletions(-) [+] |
line wrap: on
line diff
--- a/example/fft/main.cc Sat Feb 07 02:34:46 2015 +0900 +++ b/example/fft/main.cc Thu Feb 12 17:04:03 2015 +0900 @@ -32,6 +32,7 @@ cl_command_queue queue = NULL; cl_program program = NULL; CPU_TYPE spe_cpu = SPE_ANY; +bool flip_flag = false; cl_float2* xm; cl_float2* rm; @@ -126,7 +127,7 @@ brev->set_inData(0, src, length_src*sizeof(cl_float2)); brev->set_outData(0, dst, length_dst*sizeof(cl_float2)); brev->set_cpu(spe_cpu); - brev->flip(); + if (flip_flag)brev->flip(); brev->wait_for(waitTask); brev->iterate(gws[0],gws[1]); @@ -142,7 +143,7 @@ bfly->set_inData(1, spin, sizeof(cl_float2)*(n/2)); bfly->set_outData(0, dst,length_dst*sizeof(cl_float2)); bfly->set_cpu(spe_cpu); - bfly->flip(); + if (flip_flag)bfly->flip(); bfly->wait_for(waitTask); bfly->iterate(gws[0],gws[1]); waitTask = bfly; @@ -152,7 +153,7 @@ setWorkSize(gws,lws,n,n); HTask *norm = manager->create_task(NORMALIZATION); norm->set_inData(0, dst,length_dst*sizeof(cl_float2)); - if (!last) + if ( (!last)&&flip_flag ) norm->flip(); norm->set_outData(0, dst, length_dst*sizeof(cl_float2)); norm->set_param(0,n); @@ -178,7 +179,9 @@ spe_cpu = GPU_0; } else if (strcmp(argv[i], "-any") == 0) { spe_cpu = ANY_ANY; - } + } else if (strcmp(argv[i], "-flip") == 0) { + flip_flag = true; + } } if ( (argc == 1)||(filename==0)) { printf("Usage: ./fft -file [image filename] -cpu or -gpu\n"); @@ -230,7 +233,7 @@ sfac->set_outData(0, wm, length_w*sizeof(cl_float2)); sfac->set_param(0,n); sfac->set_cpu(spe_cpu); - sfac->flip(); + if (flip_flag)sfac->flip(); sfac->iterate(gws[0]); // Butterfly Operation @@ -244,7 +247,7 @@ first_trns->set_outData(0,xm,length_r*sizeof(cl_float2)); first_trns->set_param(0,n); first_trns->set_cpu(spe_cpu); - first_trns->flip(); + if (flip_flag)first_trns->flip(); first_trns->wait_for(waitTask); first_trns->iterate(gws[0],gws[1]); @@ -260,7 +263,7 @@ hpfl->set_param(0,n); hpfl->set_param(1,(long)radius); hpfl->set_cpu(spe_cpu); - hpfl->flip(); + if (flip_flag) hpfl->flip(); hpfl->wait_for(waitTask); hpfl->iterate(gws[0],gws[1]); @@ -276,7 +279,7 @@ second_trns->set_outData(0,rm,length_r*sizeof(cl_float2)); second_trns->set_param(0,n); second_trns->set_cpu(spe_cpu); - second_trns->flip(); + if (flip_flag)second_trns->flip(); second_trns->wait_for(waitTask); second_trns->iterate(gws[0],gws[1]);