changeset 126:f57e9ffa7960

add comment rb_tree
author ikkun
date Wed, 14 Sep 2016 20:35:21 +0900
parents e3cba827d489
children a574ba0da60f
files src/parallel_execution/CMakeLists.txt src/parallel_execution/main.c src/parallel_execution/stack.c
diffstat 3 files changed, 33 insertions(+), 33 deletions(-) [+]
line wrap: on
line diff
--- a/src/parallel_execution/CMakeLists.txt	Tue May 03 17:29:21 2016 +0900
+++ b/src/parallel_execution/CMakeLists.txt	Wed Sep 14 20:35:21 2016 +0900
@@ -1,9 +1,9 @@
 cmake_minimum_required(VERSION 2.8)
 
 # -DUSE_CUDA
-add_definitions("-Wall -g -O0")
+add_definitions("-Wall -g -O")
 
-set(CMAKE_C_COMPILER clang)
+set(CMAKE_C_COMPILER /Users/one/src/cbclang/Debug+Asserts/bin/clang)
 
 add_executable(twice
                main.c
--- a/src/parallel_execution/main.c	Tue May 03 17:29:21 2016 +0900
+++ b/src/parallel_execution/main.c	Wed Sep 14 20:35:21 2016 +0900
@@ -8,8 +8,8 @@
 extern void allocator(struct Context* context);
 
 int cpu_num = 1;
-int length = 1024;
-int split;
+int length = 102400;
+int split = 8;
 int* array_ptr;
 
 void print_queue(struct Element* element) {
--- a/src/parallel_execution/stack.c	Tue May 03 17:29:21 2016 +0900
+++ b/src/parallel_execution/stack.c	Wed Sep 14 20:35:21 2016 +0900
@@ -2,67 +2,67 @@
 #include "stack.h"
 
 stack_ptr stack_init(size_t size, int max) {
-    stack_ptr stack_ptr;
+    stack_ptr p;
     
-    if ((stack_ptr = calloc(1, sizeof(stack))) == NULL)
+    if ((p = calloc(1, sizeof(stack))) == NULL)
         return NULL;
     
-    if ((stack_ptr->data = calloc(max, size)) == NULL) {
-        free(stack_ptr);
+    if ((p->data = calloc(max, size)) == NULL) {
+        free(p);
         return NULL;
     }
 
-    stack_ptr->size = size;
-    stack_ptr->max = max;
-    stack_ptr->num = 0;
+    p->size = size;
+    p->max = max;
+    p->num = 0;
 
-    return stack_ptr;
+    return p;
 }
 
-stack_ptr stack_realloc(stack_ptr stack_ptr, int max) {
-    if (stack_ptr == NULL)
+stack_ptr stack_realloc(stack_ptr p, int max) {
+    if (p == NULL)
         return NULL;
 
-    if ((stack_ptr->data = realloc(stack_ptr->data, stack_ptr->size*max)) == NULL)
+    if ((p->data = realloc(p->data, p->size*max)) == NULL)
         return NULL;
 
-    stack_ptr->max = max;
+    p->max = max;
 
-    return stack_ptr;
+    return p;
 }
 
-void stack_free(stack_ptr stack_ptr) {
-    if (stack_ptr != NULL && stack_ptr->data != NULL) {
-        free(stack_ptr->data);
-        free(stack_ptr);
+void stack_free(stack_ptr p) {
+    if (p != NULL && p->data != NULL) {
+        free(p->data);
+        free(p);
     }
 }
     
-int stack_push(stack_ptr stack_ptr, void* data) {
-    if (stack_ptr->max <= stack_ptr->num)
+int stack_push(stack_ptr p, void* data) {
+    if (p->max <= p->num)
         return -1;
 
-    memcpy((char*)stack_ptr->data+stack_ptr->num*stack_ptr->size,  data, stack_ptr->size);
-    stack_ptr->num++;
+    memcpy((char*)p->data+p->num*p->size,  data, p->size);
+    p->num++;
 
     return 0;
 }
 
-int stack_pop(stack_ptr stack_ptr, void* data) {
-    if (stack_ptr->num == 0)
+int stack_pop(stack_ptr p, void* data) {
+    if (p->num == 0)
         return -1;
 
-    stack_ptr->num--;
+    p->num--;
 
-    memcpy(data, (char*)stack_ptr->data+stack_ptr->num*stack_ptr->size, stack_ptr->size);
+    memcpy(data, (char*)p->data+p->num*p->size, p->size);
     
     return 0;
 }
 
-int isMax(const stack_ptr stack_ptr) {
-    return stack_ptr->max<=stack_ptr->num;
+int isMax(const stack_ptr p) {
+    return p->max<=p->num;
 }
 
-int isEmpty(const stack_ptr stack_ptr) {
-    return stack_ptr->num<=0;
+int isEmpty(const stack_ptr p) {
+    return p->num<=0;
 }