diff --git a/android/AndroidManifest.xml b/android/AndroidManifest.xml index f7ec34e..931aece 100644 --- a/android/AndroidManifest.xml +++ b/android/AndroidManifest.xml @@ -1,7 +1,7 @@ diff --git a/src/common.cpp b/src/common.cpp index 5425c44..d6d7eeb 100644 --- a/src/common.cpp +++ b/src/common.cpp @@ -107,11 +107,11 @@ uint roundToPowOf2(uint number, int maxPower) int i; if ((maxPower > 0) && (number > (1 << maxPower))) - return 1 << maxPower; + return (1 << maxPower); - for (i=1 ; i < 8*sizeof(int) ; i++) + for (i=1 ; i < (8*sizeof(int)) ; i++) if ((1 << i) > number) break; - return 1 << (i-1); + return (1 << (i-1)); } diff --git a/src/global_bandwidth.cpp b/src/global_bandwidth.cpp index f98ddf0..3628a7d 100644 --- a/src/global_bandwidth.cpp +++ b/src/global_bandwidth.cpp @@ -7,6 +7,7 @@ int clPeak::runGlobalBandwidthTest(cl::CommandQueue &queue, cl::Program &prog, d { float timed_lo, timed_go, timed, gbps; cl::NDRange globalSize, localSize; + float *arr = NULL; if(!isGlobalBW) return 0; @@ -24,11 +25,11 @@ int clPeak::runGlobalBandwidthTest(cl::CommandQueue &queue, cl::Program &prog, d numItems = roundToPowOf2(maxItems); } - float *arr = new float[numItems]; - populate(arr, numItems); - try { + arr = new float[numItems]; + populate(arr, numItems); + log->print(NEWLINE TAB TAB "Global memory bandwidth (GBPS)" NEWLINE); log->xmlOpenTag("global_memory_bandwidth"); log->xmlAppendAttribs("unit", "gbps"); @@ -147,6 +148,8 @@ int clPeak::runGlobalBandwidthTest(cl::CommandQueue &queue, cl::Program &prog, d log->xmlRecord("float16", gbps); /////////////////////////////////////////////////////////////////////////// log->xmlCloseTag(); // global_memory_bandwidth + + if(arr) delete [] arr; } catch(cl::Error error) { @@ -159,7 +162,6 @@ int clPeak::runGlobalBandwidthTest(cl::CommandQueue &queue, cl::Program &prog, d return -1; } - if(arr) delete [] arr; return 0; } diff --git a/src/transfer_bandwidth.cpp b/src/transfer_bandwidth.cpp index c9c9266..47b335f 100644 --- a/src/transfer_bandwidth.cpp +++ b/src/transfer_bandwidth.cpp @@ -11,6 +11,7 @@ int clPeak::runTransferBandwidthTest(cl::CommandQueue &queue, cl::Program &prog, cl::Context ctx = queue.getInfo(); int iters = devInfo.transferBWIters; Timer timer; + float *arr = NULL; cl_uint maxItems = devInfo.maxAllocSize / sizeof(float) / 2; cl_uint numItems; @@ -22,10 +23,9 @@ int clPeak::runTransferBandwidthTest(cl::CommandQueue &queue, cl::Program &prog, numItems = roundToPowOf2(maxItems); } - float *arr = new float[numItems]; - try { + arr = new float[numItems]; cl::Buffer clBuffer = cl::Buffer(ctx, (CL_MEM_READ_WRITE | CL_MEM_ALLOC_HOST_PTR), (numItems * sizeof(float))); log->print(NEWLINE TAB TAB "Transfer bandwidth (GBPS)" NEWLINE); @@ -245,7 +245,7 @@ int clPeak::runTransferBandwidthTest(cl::CommandQueue &queue, cl::Program &prog, /////////////////////////////////////////////////////////////////////////// log->xmlCloseTag(); // transfer_bandwidth - + if(arr) delete [] arr; } catch(cl::Error error) { @@ -258,7 +258,6 @@ int clPeak::runTransferBandwidthTest(cl::CommandQueue &queue, cl::Program &prog, return -1; } - if(arr) delete [] arr; return 0; }