Changeset 798 for soft/giet_vm/applications/rosenfeld
- Timestamp:
- Mar 2, 2016, 3:08:27 PM (9 years ago)
- Location:
- soft/giet_vm/applications/rosenfeld
- Files:
-
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
soft/giet_vm/applications/rosenfeld/Makefile
r791 r798 6 6 INC_PATH = include 7 7 8 TARGET ?= linux 9 # 10 # -- Config ---------- 11 12 ifeq ($(TARGET),giet-vm) 13 14 C_DEBUG_FLAGS = -O0 15 C_OPTIM_FLAGS = -std=c99 -O2 -fstrict-aliasing 16 C_OS_FLAGS = -DGTODay -DTARGET_OS=GIETVM 17 C_CONFIG_FLAGS = -DCLI 18 C_INC_FLAGS = -I$(INC_PATH) -Inrc2/include -I../.. -I../../giet_libs -I../../giet_xml/ 19 CFLAGSCPU := -mips32 -EL -G0 -mhard-float -fomit-frame-pointer -fno-builtin -ffreestanding 20 21 LDFLAGS := -Lnrc2 -L../../build/libs -Trosenfeld.ld --start-group -lnrc2x -luser -lmath --end-group 22 23 endif 24 25 ifeq ($(TARGET),linux) 26 27 CC = gcc 28 LD = gcc 8 29 9 30 # -- Config ---------- 10 31 C_DEBUG_FLAGS = -O0 11 32 C_OPTIM_FLAGS = -std=c99 -O2 -fstrict-aliasing 12 C_OS_FLAGS = -DGTODay 33 C_OS_FLAGS = -DGTODay -DTARGET_OS=LINUX 13 34 C_CONFIG_FLAGS = -DCLI 14 C_INC_FLAGS = -I$(INC_PATH) -Inrc2/include -I../.. -I../../giet_libs -I../../giet_xml/ 35 C_INC_FLAGS = -I$(INC_PATH) -Inrc2/include 36 CFLAGSCPU = 37 38 LDFLAGS := -Lnrc2 -Wl,--start-group -lnrc2x -lm -Wl,--end-group 39 40 endif 41 42 43 44 CFLAGSW := -Wredundant-decls -Wdisabled-optimization -Winline -Wpointer-arith -Wsign-compare -Wendif-labels -Wno-unused-function 15 45 16 46 # -- Flags ---------- 17 47 #CFLAGS = $(C_DEBUG_FLAGS) $(C_OS_FLAGS) $(C_INC_FLAGS) $(C_CONFIG_FLAGS) 18 CFLAGS = $(C_OPTIM_FLAGS) $(C_OS_FLAGS) $(C_INC_FLAGS) $(C_CONFIG_FLAGS) 48 CFLAGS = $(C_OPTIM_FLAGS) $(C_OS_FLAGS) $(C_INC_FLAGS) $(C_CONFIG_FLAGS) -g -Wall $(CFLAGSW) $(CFLAGSCPU) 19 49 20 50 … … 28 58 29 59 30 CFLAGSW := -Wredundant-decls -Wdisabled-optimization -Winline -Wpointer-arith -Wsign-compare -Wendif-labels31 CFLAGSCPU := -mips32 -EL -G0 -mhard-float32 CFLAGS := $(CFLAGS) -g -Wall -fomit-frame-pointer $(CFLAGSW) $(CFLAGSCPU) -I$(INC_PATH) -fno-builtin -ffreestanding33 60 34 LDFLAGS := -Lnrc2 -L../../build/libs -Trosenfeld.ld --start-group -lnrc2x -luser -lmath --end-group35 61 36 62 -
soft/giet_vm/applications/rosenfeld/nrc2/Makefile
r793 r798 7 7 8 8 # -- File list ---------- 9 FILE = nralloc1.c, nralloc2.c, nralloc2x.c, nrarith0.c, nrarith1.c, nrarith2.c, nrarith2x.c, nrbool1.c, nrbool2.c, 9 FILE = nralloc1.c, nralloc2.c, nralloc2x.c, nrarith0.c, nrarith1.c, nrarith2.c, nrarith2x.c, nrbool1.c, nrbool2.c, nrhisto.c, nrio0.c, nrio1.c, nrio2.c, nrkernel.c, nrlinalg.c, nrlut.c, nrmem1.c, nrmem1x.c, nrmem2.c, nrmem2x.c, nrset1.c, nrset2.c, nrset2x.c, nrsort1.c, nrsort2.c, nrwrap1.c, nrwrap2.c 10 10 11 11 … … 19 19 C_DEBUG_FLAGS = -O0 20 20 C_OPTIMISATION_FLAGS = -std=c99 -O2 -fstrict-aliasing 21 C_OS_FLAGS = -DGTODay 21 C_OS_FLAGS = -DGTODay -DTARGET_OS=GIETVM 22 22 C_CONFIG_FLAGS = -DCLI 23 23 C_INC_FLAGS = -I$(INC_PATH) -I../../.. -I../../../giet_libs … … 41 41 CFLAGSW := -Wredundant-decls -Wdisabled-optimization -Winline -Wpointer-arith -Wsign-compare -Wendif-labels 42 42 CFLAGSCPU := -mips32 -EL -G0 -mhard-float 43 CFLAGS := $(CFLAGS) -g -Wall -fomit-frame-pointer $(CFLAGSW) $(CFLAGSCPU) - I$(DIR_INC) -fno-builtin -ffreestanding43 CFLAGS := $(CFLAGS) -g -Wall -fomit-frame-pointer $(CFLAGSW) $(CFLAGSCPU) -fno-builtin -ffreestanding 44 44 45 45 -
soft/giet_vm/applications/rosenfeld/nrc2/include/nrc_os_config.h
r791 r798 1 1 2 #define TARGET_OS GIETVM3 2 4 #if TARGET_OS==GIETVM 3 #define GIETVM 1 4 #define LINUX 2 5 6 #if TARGET_OS == GIETVM 5 7 #define printf(...) giet_tty_printf(__VA_ARGS__) 6 8 … … 12 14 #define fscanf(x, ...) ; 13 15 #define exit(x) giet_pthread_exit(NULL) 16 #else 14 17 #endif 15 18 -
soft/giet_vm/applications/rosenfeld/nrc2/include/nrio2.h
r772 r798 239 239 IMAGE_EXPORT(uint8 **) LoadPGM_bmatrix (char *filename, int *nrl, int *nrh, int *ncl, int *nch); 240 240 IMAGE_EXPORT(void) LoadPGM_bmatrix2 (char *filename, int *nrl, int *nrh, int *ncl, int *nch, uint8 **m); 241 IMAGE_EXPORT(void) MLoadPGM_bmatrix(char *filename, int nrl, int nrh, int ncl, int nch, uint8 **m);241 IMAGE_EXPORT(void) MLoadPGM_bmatrix (char *filename, int nrl, int nrh, int ncl, int nch, uint8 **m); 242 242 243 243 IMAGE_EXPORT(void) SavePGM_bmatrix (uint8 **m, int nrl, int nrh, int ncl, int nch, char *filename); 244 244 IMAGE_EXPORT(void) SavePGM_ui8matrix(uint8 **m, int nrl, int nrh, int ncl, int nch, char *filename); 245 245 246 IMAGE_EXPORT(rgb8 **) LoadPPM_rgb8matrix (char *filename, int *nrl, int *nrh, int *ncl, int *nch); 247 IMAGE_EXPORT(void) LoadPPM_rgb8matrix2(char *filename, int *nrl, int *nrh, int *ncl, int *nch, rgb8 **m); 248 249 IMAGE_EXPORT(void) SavePPM_rgb8matrix(rgb8 **m, int nrl, int nrh, int ncl, int nch, char *filename); 246 IMAGE_EXPORT(rgb8 **) LoadPPM_rgb8matrix (char *filename, int *nrl, int *nrh, int *ncl, int *nch); 247 IMAGE_EXPORT(void) LoadPPM_rgb8matrix2(char *filename, int *nrl, int *nrh, int *ncl, int *nch, rgb8 **m); 248 249 IMAGE_EXPORT(void) SavePPM_rgb8matrix(rgb8 **m, int nrl, int nrh, int ncl, int nch, char *filename); 250 251 252 250 253 #ifdef __cplusplus 251 254 } -
soft/giet_vm/applications/rosenfeld/nrc2/src/nrio2.c
r772 r798 13 13 14 14 #include <stdio.h> 15 #include <stddef.h>16 15 #include <stdlib.h> 16 #include <string.h> 17 17 18 18 #include "nrc_os_config.h" 19 20 #if TARGET_OS == LINUX 21 #include <sys/types.h> 22 #include <sys/stat.h> 23 #include <fcntl.h> 24 #include <unistd.h> 25 #endif 26 27 19 28 #include "mypredef.h" 20 29 #include "nrtype.h" … … 28 37 #include "nrio1.h" 29 38 #include "nrio2.h" 39 40 #define isalnum(x) (((x) >= 0x30 && (x) <= 0x39) \ 41 || ((x) >= 0x41 && (x) <= 0x5A) \ 42 || ((x) >= 0x61 && (x) <= 0x7A)) 43 30 44 31 45 /* … … 870 884 } 871 885 } 886 887 888 889 /* --------------------------------------- */ 890 static char * readitem(int fd, char * buffer) 891 /* --------------------------------------- */ 892 { 893 char * aux; 894 int k; 895 int n; 896 897 k = 0; 898 aux = buffer; 899 while (1) { 900 n = read(fd, aux, 1); 901 if (n == 0) { 902 break; 903 } 904 switch (k) { 905 case 0: 906 if (*aux == '#') { 907 k = 1; 908 } 909 if (isalnum(*aux)) { 910 k = 2; 911 aux++; 912 } 913 break; 914 case 1: 915 if (*aux == 0xA) { 916 k = 0; 917 } 918 break; 919 case 2: 920 if (!isalnum(*aux)) { 921 *aux = 0; 922 return buffer; 923 } 924 aux++; 925 break; 926 } 927 } 928 *aux = 0; 929 return buffer; 930 } 931 932 933 /* ------------------------------------------------- */ 934 static void ReadPGMrow(int fd, int width, uint8 * line) 935 /* ------------------------------------------------- */ 936 { 937 read(fd, &line[0], sizeof(uint8) * width); 938 } 939 940 941 /* -------------------------------------------------- */ 942 static void WritePGMrow(uint8 * line, int width, int fd) 943 /* -------------------------------------------------- */ 944 { 945 write(fd, &line[0], sizeof(uint8) * width); 946 } 947 948 949 /* ----------------------------------------------------------------------------------------------- */ 950 IMAGE_EXPORT(uint8 **) LoadPGM_ui8matrix(char * filename, int * nrl, int * nrh, int * ncl, int * nch) 951 /* ----------------------------------------------------------------------------------------------- */ 952 { 953 // only for P5 binary type, not for text type 954 955 int height, width, gris; 956 uint8 ** m; 957 int fd; 958 959 char buffer[80]; 960 int i; 961 962 // open file 963 fd = open(filename, O_RDONLY); 964 if (fd < 0) { 965 printf("*** Error: Can't open file %s in %s.\n", filename, __func__); 966 } 967 968 // read PGM header 969 readitem(fd, &buffer[0]); 970 if (strcmp(&buffer[0], "P5") != 0) { 971 printf("*** Error: Invalid file header in file %s\n", filename); 972 } 973 974 width = atoi(readitem(fd, &buffer[0])); 975 height = atoi(readitem(fd, &buffer[0])); 976 gris = atoi(readitem(fd, &buffer[0])); 977 978 *nrl = 0; 979 *nrh = height - 1; 980 *ncl = 0; 981 *nch = width - 1; 982 m = ui8matrix(*nrl, *nrh, *ncl, *nch); 983 984 for (i = 0; i < height; i++) { 985 ReadPGMrow(fd, width, m[i]); 986 } 987 988 close(fd); 989 990 return m; 991 } 992 993 994 /* ----------------------------------------------------------------------------------------------- */ 995 IMAGE_EXPORT(void) SavePGM_ui8matrix(uint8 ** m, int nrl, int nrh, int ncl, int nch, char * filename) 996 /* ----------------------------------------------------------------------------------------------- */ 997 { 998 int nrow = nrh - nrl + 1; 999 int ncol = nch - ncl + 1; 1000 1001 char buffer[80]; 1002 1003 int fd; 1004 int i; 1005 1006 fd = open(filename, O_TRUNC | O_CREAT); 1007 if (fd < 0) { 1008 printf("*** Error: Impossible to open file %s in %s\n", filename, __func__); 1009 } 1010 1011 /* enregistrement de l'image au format rpgm */ 1012 snprintf(buffer, 80, "P5\n%d %d\n255\n", ncol, nrow); 1013 write(fd, buffer, strlen(buffer)); 1014 for (i = nrl; i <= nrh; i++) { 1015 WritePGMrow(m[i], ncol, fd); 1016 } 1017 1018 /* fermeture du fichier */ 1019 close(fd); 1020 } 1021 1022 1023 -
soft/giet_vm/applications/rosenfeld/rosenfeld.py
r791 r798 44 44 45 45 heap_base = 0x60000000 46 heap_size = 0x0 0200000 # 2Mbytes (per cluster)46 heap_size = 0x01000000 # 16 Mbytes (per cluster) 47 47 48 48 # create vspace 49 vspace = mapping.addVspace( name = 'rosenfeld', startname = 'rosen_data' )49 vspace = mapping.addVspace( name = 'rosenfeld', startname = 'rosen_data', active = True ) 50 50 51 51 # data vseg : shared (only in cluster[0,0]) -
soft/giet_vm/applications/rosenfeld/src/bmpNR.c
r772 r798 10 10 #include <stdlib.h> 11 11 #include <math.h> 12 13 12 14 13 /* -- image -- */ … … 20 19 #include "nralloc.h" 21 20 #endif 21 22 #if TARGET_OS == LINUX 23 #include <sys/types.h> 24 #include <sys/stat.h> 25 #include <fcntl.h> 26 #include <unistd.h> 27 #endif 28 22 29 23 30 #include "palette.h" … … 242 249 //DEBUG(printf("BMP : %d %d\n", sizeof( BitmapFileHeader), sizeof( BitmapInfoHeader))); 243 250 if (sizeof(BitmapFileHeader) != 14) { 244 printf("*** Error SaveMBP: sizeof(BitmapFileHeader) = %d should be 14...\n", sizeof(BitmapFileHeader));251 printf("*** Error SaveMBP: sizeof(BitmapFileHeader) = %d should be 14...\n", (int) sizeof(BitmapFileHeader)); 245 252 } 246 253 -
soft/giet_vm/applications/rosenfeld/src/dummy_func.c
r792 r798 10 10 11 11 12 13 IMAGE_EXPORT(uint8 **) LoadPGM_ui8matrix(char *filename, int *nrl, int *nrh, int *ncl, int *nch) { return NULL; }14 IMAGE_EXPORT(void) SavePGM_ui8matrix(uint8 **m, int nrl, int nrh, int ncl, int nch, char *filename) {}15 16 12 void write_ui8matrix_positive (uint8 **m,int i0, int i1, int j0, int j1, int iformat, char *filename) {} 17 13 -
soft/giet_vm/applications/rosenfeld/src/ecc_common.c
r777 r798 8 8 #include <math.h> 9 9 10 11 10 #ifdef CLI 12 11 #include "nrc_os_config.h" 13 12 #include "nrc.h" 14 13 #endif 14 15 #if TARGET_OS == LINUX 16 #include <sys/types.h> 17 #include <sys/stat.h> 18 #include <fcntl.h> 19 #endif 20 15 21 16 22 #include "ecc_common.h" -
soft/giet_vm/applications/rosenfeld/src/ecc_features.c
r772 r798 19 19 #include <malloc.h> 20 20 21 #ifdef OPENMP22 #include <omp.h>23 #endif24 21 25 22 #ifdef CLI 26 23 #include "nrc_os_config.h" 27 24 #include "nrc.h" 25 #endif 26 27 28 29 #if TARGET_OS == LINUX 30 #include <sys/types.h> 31 #include <sys/stat.h> 32 #include <fcntl.h> 33 #endif 34 35 36 #ifdef OPENMP 37 #include <omp.h> 28 38 #endif 29 39 … … 147 157 // --------------------------------- 148 158 { 149 int ne ;159 int ne = 0; 150 160 // @QM giet 151 161 fscanf(fd, "%d", &ne); … … 162 172 // -------------------------------------------------------------- 163 173 { 164 int i , t;174 int i; 165 175 166 176 for (i = 1; i <= ne; i++) { -
soft/giet_vm/applications/rosenfeld/src/ecc_main_rosenfeld_sa.c
r791 r798 159 159 // --------------------------------------------------------------------- 160 160 { 161 printf("[---------------------------]"); 162 printf("[--- main_rosenfeld_file ---]"); 163 printf("[---------------------------]"); 164 165 char *pathSrc = src_path; 166 char *pathDst = dst_path; 167 168 uint8 **X0, **X; 169 uint8 **E8; 170 171 uint32 **E32; 172 uint32 *S; // Stack for Bailey algorithm 173 174 uint32 *T; 175 uint32 *A; 176 uint32 *N; 177 //uint32 *SNE; // memorisation de la somme des ne: sne 161 printf("[---------------------------]\n"); 162 printf("[--- main_rosenfeld_file ---]\n"); 163 printf("[---------------------------]\n"); 164 165 char * pathSrc = src_path; 166 char * pathDst = dst_path; 167 168 uint8 ** X0; 169 uint8 ** X; 170 uint8 ** E8; 171 172 uint32 ** E32; 173 uint32 * S; // Stack for Bailey algorithm 174 175 uint32 * T; 176 uint32 * A; 177 uint32 * N; 178 //uint32 * SNE; // memorisation de la somme des ne: sne 178 179 179 180 int i0, i1, j0, j1; 180 int height, width, border =1;181 int height, width, border = 1; 181 182 uint32 nemax, nermax; 182 183 int na; … … 191 192 192 193 // chargement d'une image depuis le disque 193 //X0 = LoadPGM_ui8matrix(complete_filename, &i0, &i1, &j0, &j1); 194 init_forme_boulon1(&X0, &i0, &i1, &j0, &j1); 195 194 printf("Loading file %s... ", filename); 195 X0 = LoadPGM_ui8matrix(complete_filename, &i0, &i1, &j0, &j1); 196 //init_forme_boulon1(&X0, &i0, &i1, &j0, &j1); 197 printf("done.\n"); 198 199 printf("Allocating memory... "); 196 200 // allocation memoire 197 201 X = ui8matrix (i0 - border, i1 + border, j0 - border, j1 + border); … … 206 210 // pre-traitements 207 211 binarisation_ui8matrix(X0, i0, i1, j0, j1, 20, 1, X); // pour le traitement 208 //binarisation_ui8matrix(X0, i0, i1, j0, j1, 20, 255, X0); // pour la verif visuelle 209 //generate_path_filename(pathDst, "verif.pgm", complete_filename, 1024); 210 //SavePGM_ui8matrix(X0, i0, i1, j0, j1, complete_filename); 212 binarisation_ui8matrix(X0, i0, i1, j0, j1, 20, 255, X0); // pour la verif visuelle 213 printf("done.\n"); 214 215 printf("Saving file %s for verification... ", complete_filename); 216 generate_path_filename(pathDst, "verif.pgm", complete_filename, 1024); 217 SavePGM_ui8matrix(X0, i0, i1, j0, j1, complete_filename); 218 printf("done.\n"); 211 219 212 220 height = i1 - i0 + 1; … … 246 254 /*na = Rosenfeld_UF_Org2_4C (X, height, width, E32, T, A, nemax, Stats); ECC_VERBOSE(printf("na = %d\n", na)); filename = "Rosenfeld_UF_Org2_4C.bmp"; mod_ui32matrix_ui8matrix(E32, i0, i1, j0, j1, E8); generate_path_filename(pathDst, filename, complete_filename); SaveBMP2_ui8matrix(E8, width, height, palette, complete_filename); zero_ui32matrix(E32, i0-border, i1+border, j0-border, j1+border); display_RegionStatsVector(Stats, 1, na, "Stats"); zero_RegionStatsVector(Stats, 0, nemax);*/ 247 255 248 free_ui8matrix (X0, i0, i1, j0,j1);249 free_ui8matrix (X, i0 -border, i1+border, j0-border, j1+border);250 free_ui8matrix (E8, i0 -border, i1+border, j0-border, j1+border);251 free_ui32matrix(E32, i0 -border, i1+border, j0-border, j1+border);256 free_ui8matrix (X0, i0, i1, j0, j1); 257 free_ui8matrix (X, i0 - border, i1 + border, j0 - border, j1 + border); 258 free_ui8matrix (E8, i0 - border, i1 + border, j0 - border, j1 + border); 259 free_ui32matrix(E32, i0 - border, i1 + border, j0 - border, j1 + border); 252 260 253 261 free_ui32vector(T, 0, nemax); … … 255 263 free_ui32vector(N, 0, nemax); 256 264 257 free_ui32vector(S, 0, 2 *nermax);265 free_ui32vector(S, 0, 2 * nermax); 258 266 259 267 return; … … 267 275 char *dst_path; 268 276 269 printf("[======================] ");270 printf("[=== main_rosenfeld ===] ");271 printf("[======================] ");272 273 src_path = " ./"; // ne pas oublier le / a la fin277 printf("[======================]\n"); 278 printf("[=== main_rosenfeld ===]\n"); 279 printf("[======================]\n"); 280 281 src_path = "/misc/"; // ne pas oublier le / a la fin 274 282 dst_path = ""; 275 283 … … 287 295 int i; 288 296 289 printf("================= ");290 printf("== display_arg == ");291 printf("================= ");292 printf(" ");297 printf("=================\n"); 298 printf("== display_arg ==\n"); 299 printf("=================\n"); 300 printf("\n"); 293 301 294 302 printf("argc = %d\n", argc); … … 297 305 printf("%s ", argv[i]); 298 306 } 299 printf(" ");307 printf("\n"); 300 308 } 301 309 // ----------------------- … … 303 311 // ----------------------- 304 312 { 305 printf("===================== ");306 printf("== ecc_info_define == ");307 printf("===================== ");308 printf(" ");313 printf("=====================\n"); 314 printf("== ecc_info_define ==\n"); 315 printf("=====================\n"); 316 printf("\n"); 309 317 ecc_info_omp(); 310 318 //Label_Display_Info(); 311 printf(" ");319 printf("\n"); 312 320 } 313 321 // ----------------------------- 314 intmain(int argc, char* argv[])322 __attribute__((constructor)) void main(int argc, char* argv[]) 315 323 // ----------------------------- 316 324 { 317 #if TARGET_OS ==GIET_VM325 #if TARGET_OS == GIETVM 318 326 giet_tty_alloc(1); 327 heap_init(0, 0); 319 328 #endif 320 329 display_arg(argc, argv); … … 322 331 main_rosenfeld(argc, argv); 323 332 printf("[main]: bye"); 324 return 0;325 } 333 exit(0); 334 }
Note: See TracChangeset
for help on using the changeset viewer.