changeset 1853:f800f61a0311 draft

to prevent overrun +1 alloc in many_task
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Sat, 21 Dec 2013 19:56:58 +0900
parents 7e9ebc1b08b6
children c21bd32e20b9
files example/many_task/gpu/QuickSort.cl example/many_task/main.cc example/many_task/ppe/QuickSort.cc
diffstat 3 files changed, 3 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/example/many_task/gpu/QuickSort.cl	Sat Dec 21 19:53:05 2013 +0900
+++ b/example/many_task/gpu/QuickSort.cl	Sat Dec 21 19:56:58 2013 +0900
@@ -47,7 +47,7 @@
             data[where].index = data[begin].index;
             int i;
             p = begin;
-            for (i=begin+1; i<end; i++) {
+            for (i=begin+1; i<=end; i++) {
                 if (data[i].index < pivot) {
                     p++;
                     swap(data, p, i);
--- a/example/many_task/main.cc	Sat Dec 21 19:53:05 2013 +0900
+++ b/example/many_task/main.cc	Sat Dec 21 19:56:58 2013 +0900
@@ -111,7 +111,7 @@
     sorter.cpuNum = (long)a;
     long length = (long)b;
 
-    sorter.data = (DataPtr)manager->allocate(sizeof(Data)*length);
+    sorter.data = (DataPtr)manager->allocate(sizeof(Data)*(length+1));
     sorter.data_length = length;
 
     sorter.split_num = get_split_num(sorter.data_length, sorter.cpuNum); // data の分割数
--- a/example/many_task/ppe/QuickSort.cc	Sat Dec 21 19:53:05 2013 +0900
+++ b/example/many_task/ppe/QuickSort.cc	Sat Dec 21 19:56:58 2013 +0900
@@ -57,7 +57,7 @@
 	data[where].index = data[begin].index;
 	int p = begin;
 	int i;
-	for (i=begin+1; i<end; i++) {
+	for (i=begin+1; i<=end; i++) {
 	    if (data[i].index < pivot) { 
 		p++; 
 		swap(data, p, i);