00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #include "flgrCoreMalloc.h"
00022 #include "flgrCoreThreads.h"
00023 #include "flgrCoreThreadsAuto.h"
00024
00025
00026
00034 int __internal_fulguro_thread_data2d_data2d(void *param) {
00035 FLGR_ThreadsArg *arg = (FLGR_ThreadsArg *) param;
00036 FLGR_Fct_data2d_data2d *fct = (FLGR_Fct_data2d_data2d *) arg->argv[0];
00037
00038 FLGR_Data2D *p1 = (FLGR_Data2D *) arg->argv[1];
00039 FLGR_Data2D *p2 = (FLGR_Data2D *) arg->argv[2];
00040
00041 return (int) ((*fct)(p1,p2));
00042
00043 }
00044
00045
00046 int __internal_fulguro_thread_data2d_data2d_nhb(void *param) {
00047 FLGR_ThreadsArg *arg = (FLGR_ThreadsArg *) param;
00048 FLGR_Fct_data2d_data2d_data2d *fct = (FLGR_Fct_data2d_data2d_data2d *) arg->argv[0];
00049
00050 FLGR_Data2D *p1 = (FLGR_Data2D *) arg->argv[1];
00051 FLGR_Data2D *p2 = (FLGR_Data2D *) arg->argv[2];
00052 FLGR_Data2D *p3 = (FLGR_Data2D *) arg->argv[3];
00053
00054 return (int) ((*fct)(p1,p2,p3));
00055
00056 }
00057
00058
00059 int __internal_fulguro_thread_data2d_data2d_data2d(void *param) {
00060 FLGR_ThreadsArg *arg = (FLGR_ThreadsArg *) param;
00061 FLGR_Fct_data2d_data2d_data2d *fct = (FLGR_Fct_data2d_data2d_data2d *) arg->argv[0];
00062
00063 FLGR_Data2D *p1 = (FLGR_Data2D *) arg->argv[1];
00064 FLGR_Data2D *p2 = (FLGR_Data2D *) arg->argv[2];
00065 FLGR_Data2D *p3 = (FLGR_Data2D *) arg->argv[3];
00066
00067 return (int) ((*fct)(p1,p2,p3));
00068
00069 }
00070
00071
00073
00081
00082 FLGR_Ret flgr2d_thread_function_data2d_data2d(FLGR_Fct_data2d_data2d *fct_ptr, FLGR_Data2D *p1, FLGR_Data2D *p2, int thread_number) {
00083
00084 FLGR_Data2D **p1_link = (FLGR_Data2D **) flgr_malloc(sizeof(FLGR_Data2D*) * thread_number);
00085 FLGR_Data2D **p2_link = (FLGR_Data2D **) flgr_malloc(sizeof(FLGR_Data2D*) * thread_number);
00086 FLGR_ThreadsArgList *arglist = flgr_threads_create_argument_list(thread_number);
00087 int i;
00088
00089 if( (fct_ptr == NULL) || (p1==NULL) || (p2==NULL) ) {
00090 POST_ERROR("Null objects\n");
00091 return FLGR_RET_NULL_OBJECT;
00092 }
00093
00094 if(thread_number<=0) {
00095 thread_number=1;
00096 }
00097
00098 for(i=0 ; i<thread_number ; i++) {
00099 p1_link[i] = flgr2d_create_pixmap_link(p1, thread_number, i, 0);
00100 p2_link[i] = flgr2d_create_pixmap_link(p2, thread_number, i, 0);
00101
00102 flgr_threads_set_argument(arglist, i, 3, fct_ptr, p1_link[i], p2_link[i]);
00103 }
00104
00105 flgr_threads_start(arglist, thread_number, 1, __internal_fulguro_thread_data2d_data2d);
00106
00107 flgr_threads_destroy_argument_list(arglist);
00108
00109 for(i=0 ; i<thread_number ; i++) {
00110 flgr2d_destroy_link(p1_link[i]);
00111 flgr2d_destroy_link(p2_link[i]);
00112 }
00113
00114 flgr_free(p1_link);
00115 flgr_free(p2_link);
00116
00117 return FLGR_RET_OK;
00118 }
00119
00120
00121
00123
00132
00133 FLGR_Ret flgr2d_thread_function_data2d_data2d_nhb(FLGR_Fct_data2d_data2d_data2d *fct_ptr, FLGR_Data2D *p1, FLGR_Data2D *p2, FLGR_Data2D *nhb,
00134 int thread_number) {
00135
00136 FLGR_Data2D **p1_link = (FLGR_Data2D **) flgr_malloc(sizeof(FLGR_Data2D*) * thread_number);
00137 FLGR_Data2D **p2_link = (FLGR_Data2D **) flgr_malloc(sizeof(FLGR_Data2D*) * thread_number);
00138 FLGR_ThreadsArgList *arglist = flgr_threads_create_argument_list(thread_number);
00139 int overlap = nhb->size_y/2;
00140 int i;
00141
00142 if( (fct_ptr == NULL) || (p1==NULL) || (p2==NULL) || (nhb==NULL) ) {
00143 POST_ERROR("Null objects\n");
00144 return FLGR_RET_NULL_OBJECT;
00145 }
00146
00147 if(thread_number<=0) {
00148 thread_number=1;
00149 }
00150
00151 for(i=0 ; i<thread_number ; i++) {
00152 p1_link[i] = flgr2d_create_pixmap_link(p1, thread_number, i, overlap);
00153 p2_link[i] = flgr2d_create_pixmap_link(p2, thread_number, i, overlap);
00154
00155 flgr_threads_set_argument(arglist, i, 4, fct_ptr, p1_link[i], p2_link[i], nhb);
00156 }
00157
00158 flgr_threads_start(arglist, thread_number, 1, __internal_fulguro_thread_data2d_data2d_nhb);
00159
00160 flgr_threads_destroy_argument_list(arglist);
00161
00162 for(i=0 ; i<thread_number ; i++) {
00163 flgr2d_destroy_link(p1_link[i]);
00164 flgr2d_destroy_link(p2_link[i]);
00165 }
00166
00167 flgr_free(p1_link);
00168 flgr_free(p2_link);
00169
00170 return FLGR_RET_OK;
00171 }
00172
00173
00174
00176
00185
00186 FLGR_Ret flgr2d_thread_function_data2d_data2d_data2d(FLGR_Fct_data2d_data2d_data2d *fct_ptr, FLGR_Data2D *p1, FLGR_Data2D *p2, FLGR_Data2D *p3,
00187 int thread_number) {
00188
00189 FLGR_Data2D **p1_link = (FLGR_Data2D **) flgr_malloc(sizeof(FLGR_Data2D*) * thread_number);
00190 FLGR_Data2D **p2_link = (FLGR_Data2D **) flgr_malloc(sizeof(FLGR_Data2D*) * thread_number);
00191 FLGR_Data2D **p3_link = (FLGR_Data2D **) flgr_malloc(sizeof(FLGR_Data2D*) * thread_number);
00192 FLGR_ThreadsArgList *arglist = flgr_threads_create_argument_list(thread_number);
00193 int i;
00194
00195 if( (fct_ptr == NULL) || (p1==NULL) || (p2==NULL) || (p3==NULL) ) {
00196 POST_ERROR("Null objects\n");
00197 return FLGR_RET_NULL_OBJECT;
00198 }
00199
00200 if(thread_number<=0) {
00201 thread_number=1;
00202 }
00203
00204 for(i=0 ; i<thread_number ; i++) {
00205 p1_link[i] = flgr2d_create_pixmap_link(p1, thread_number, i, 0);
00206 p2_link[i] = flgr2d_create_pixmap_link(p2, thread_number, i, 0);
00207 p3_link[i] = flgr2d_create_pixmap_link(p3, thread_number, i, 0);
00208
00209 flgr_threads_set_argument(arglist, i, 4, fct_ptr, p1_link[i], p2_link[i], p3_link[i]);
00210 }
00211
00212 flgr_threads_start(arglist, thread_number, 1, __internal_fulguro_thread_data2d_data2d_data2d);
00213
00214 flgr_threads_destroy_argument_list(arglist);
00215
00216 for(i=0 ; i<thread_number ; i++) {
00217 flgr2d_destroy_link(p1_link[i]);
00218 flgr2d_destroy_link(p2_link[i]);
00219 flgr2d_destroy_link(p3_link[i]);
00220 }
00221
00222 flgr_free(p1_link);
00223 flgr_free(p2_link);
00224 flgr_free(p3_link);
00225
00226 return FLGR_RET_OK;
00227 }
00228
00229
00230