00001
00002
00003
00004
00005
00006
00007
00008 #include "./dataloop.h"
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 int PREPEND_PREFIX(Dataloop_create_contiguous)(int icount,
00026 DLOOP_Type oldtype,
00027 DLOOP_Dataloop **dlp_p,
00028 int *dlsz_p,
00029 int *dldepth_p,
00030 int flag)
00031 {
00032 DLOOP_Count count;
00033 int is_builtin, apply_contig_coalescing = 0;
00034 int new_loop_sz, new_loop_depth;
00035
00036 DLOOP_Dataloop *new_dlp;
00037
00038 count = (DLOOP_Count) icount;
00039
00040 is_builtin = (DLOOP_Handle_hasloop_macro(oldtype)) ? 0 : 1;
00041
00042 if (is_builtin)
00043 {
00044 new_loop_depth = 1;
00045 }
00046 else
00047 {
00048 int old_loop_sz = 0, old_loop_depth = 0;
00049 DLOOP_Offset old_size = 0, old_extent = 0;
00050 DLOOP_Dataloop *old_loop_ptr;
00051
00052 DLOOP_Handle_get_loopsize_macro(oldtype, old_loop_sz, flag);
00053 DLOOP_Handle_get_loopdepth_macro(oldtype, old_loop_depth, flag);
00054 DLOOP_Handle_get_loopptr_macro(oldtype, old_loop_ptr, flag);
00055 DLOOP_Handle_get_size_macro(oldtype, old_size);
00056 DLOOP_Handle_get_extent_macro(oldtype, old_extent);
00057
00058
00059 if (((old_loop_ptr->kind & DLOOP_KIND_MASK) == DLOOP_KIND_CONTIG)
00060 && (old_size == old_extent))
00061 {
00062
00063 apply_contig_coalescing = 1;
00064 new_loop_depth = old_loop_depth;
00065 }
00066 else
00067 {
00068 new_loop_depth = old_loop_depth + 1;
00069 }
00070 }
00071
00072 if (is_builtin)
00073 {
00074 DLOOP_Offset basic_sz = 0;
00075
00076 PREPEND_PREFIX(Dataloop_alloc)(DLOOP_KIND_CONTIG,
00077 count,
00078 &new_dlp,
00079 &new_loop_sz);
00080
00081 if (!new_dlp) return -1;
00082
00083
00084 DLOOP_Handle_get_size_macro(oldtype, basic_sz);
00085 new_dlp->kind = DLOOP_KIND_CONTIG | DLOOP_FINAL_MASK;
00086
00087 if (flag == DLOOP_DATALOOP_ALL_BYTES)
00088 {
00089 count *= basic_sz;
00090 new_dlp->el_size = 1;
00091 new_dlp->el_extent = 1;
00092 new_dlp->el_type = MPI_BYTE;
00093 }
00094 else
00095 {
00096 new_dlp->el_size = basic_sz;
00097 new_dlp->el_extent = new_dlp->el_size;
00098 new_dlp->el_type = oldtype;
00099 }
00100
00101 new_dlp->loop_params.c_t.count = count;
00102 }
00103 else
00104 {
00105
00106 DLOOP_Dataloop *old_loop_ptr;
00107 int old_loop_sz = 0;
00108
00109 DLOOP_Handle_get_loopptr_macro(oldtype, old_loop_ptr, flag);
00110 DLOOP_Handle_get_loopsize_macro(oldtype, old_loop_sz, flag);
00111
00112 if (apply_contig_coalescing)
00113 {
00114
00115 PREPEND_PREFIX(Dataloop_dup)(old_loop_ptr,
00116 old_loop_sz,
00117 &new_dlp);
00118
00119 if (!new_dlp) return -1;
00120
00121
00122 new_dlp->loop_params.c_t.count *= count;
00123
00124 new_loop_sz = old_loop_sz;
00125 DLOOP_Handle_get_loopdepth_macro(oldtype, new_loop_depth, flag);
00126 }
00127 else
00128 {
00129 DLOOP_Dataloop *old_loop_ptr;
00130 int old_loop_sz = 0;
00131
00132 DLOOP_Handle_get_loopptr_macro(oldtype, old_loop_ptr, flag);
00133 DLOOP_Handle_get_loopsize_macro(oldtype, old_loop_sz, flag);
00134
00135
00136 PREPEND_PREFIX(Dataloop_alloc_and_copy)(DLOOP_KIND_CONTIG,
00137 count,
00138 old_loop_ptr,
00139 old_loop_sz,
00140 &new_dlp,
00141 &new_loop_sz);
00142
00143 if (!new_dlp) return -1;
00144
00145
00146 new_dlp->kind = DLOOP_KIND_CONTIG;
00147 DLOOP_Handle_get_size_macro(oldtype, new_dlp->el_size);
00148 DLOOP_Handle_get_extent_macro(oldtype, new_dlp->el_extent);
00149 DLOOP_Handle_get_basic_type_macro(oldtype, new_dlp->el_type);
00150
00151 new_dlp->loop_params.c_t.count = count;
00152 }
00153 }
00154
00155 *dlp_p = new_dlp;
00156 *dlsz_p = new_loop_sz;
00157 *dldepth_p = new_loop_depth;
00158
00159 return 0;
00160 }