Ignore:
Timestamp:
Jun 1, 2016, 10:25:43 AM (8 years ago)
Author:
meunier
Message:

In rosenfeld:

  • Updated nrio0, nrio1, nrio2, nrio1f, nrio2f, nrio1x, nrbool1, nrbool2 and nralloc1 in the nrc2 lib in order to use macro-typed functions
  • Updated the simulation script to include performance evaluation with random images, and a script to generate graphs
  • Updated the clock.h to use 64-bit integers, which potentially breaks the printing on the giet
File:
1 edited

Legend:

Unmodified
Added
Removed
  • soft/giet_vm/applications/rosenfeld/nrc2/src/nrio1x.c

    r772 r822  
    2121#include "nrio1x.h"
    2222
    23 /* ---------------------------------------------------------------------------------------------------------- */
    24 IMAGE_EXPORT(void) display_bvector_circular(byte *v,long nl,long nh, long c0, long c1, char *format, char *name)
    25 /* ---------------------------------------------------------------------------------------------------------- */
    26 {
    27   long i, n=nh-nl+1;
    28 
    29   if(name != NULL) puts(name);
    30 
    31   for(i=c0; i<=c1; i++) { printf(format, v[i%n+nl]);} putchar('\n');
    32 }
    33 /* ----------------------------------------------------------------------------------------------------------- */
    34 IMAGE_EXPORT(void) display_si16vector_circular(sint16 *v,long nl,long nh, long c0, long c1, char *format, char *name)
    35 /* ----------------------------------------------------------------------------------------------------------- */
    36 {
    37   long i, n=nh-nl+1;
    38 
    39   if(name != NULL) puts(name);
    40 
    41   for(i=c0; i<=c1; i++) { printf(format, v[i%n+nl]);} putchar('\n');
    42 }
    43 /* --------------------------------------------------------------------------------------------------------- */
    44 IMAGE_EXPORT(void) display_ui32vector_circular(uint32 *v,long nl,long nh, long c0, long c1, char *format, char *name)
    45 /* --------------------------------------------------------------------------------------------------------- */
    46 {
    47   long i, n=nh-nl+1;
    48 
    49   if(name != NULL) puts(name);
    50 
    51   for(i=c0; i<=c1; i++) { printf(format, v[i%n+nl]);} putchar('\n');
    52 }
    53 /* ---------------------------------------------------------------------------------------------------------- */
    54 IMAGE_EXPORT(void) display_f32vector_circular(float32 *v,long nl,long nh, long c0, long c1, char *format, char *name)
    55 /* ---------------------------------------------------------------------------------------------------------- */
    56 {
    57   long i, n=nh-nl+1;
    58 
    59   if(name != NULL) puts(name);
    60 
    61   for(i=c0; i<=c1; i++) { printf(format, v[i%n+nl]);} putchar('\n');
    62 }
    63 /* ------------------------------------------------------------------------------------------------------------ */
    64 IMAGE_EXPORT(void) display_f64vector_circular(float64 *v,long nl,long nh, long c0, long c1, char *format, char *name)
    65 /* ------------------------------------------------------------------------------------------------------------ */
    66 {
    67   long i, n=nh-nl+1;
    68 
    69   if(name != NULL) puts(name);
    70 
    71   for(i=c0; i<=c1; i++) { printf(format, v[i%n+nl]);} putchar('\n');
    72 }
    73 /* ----------------------------------------------------------------------------------------------------------------- */
    74 IMAGE_EXPORT(void) display_bvector_circular_number(byte *v,long nl,long nh, long c0, long c1, char *format, char *name)
    75 /* ----------------------------------------------------------------------------------------------------------------- */
    76 {
    77   long i, n=nh-nl+1;
    78 
    79   if(name != NULL) puts(name);
    80 
    81   putchar('#');
    82   for(i=c0; i<=c1; i++) {
    83     printf(format,   i%n+nl);
    84   }
    85   putchar('\n');
    86   putchar(' ');
    87   for(i=c0; i<=c1; i++) {
    88     printf(format, v[i%n+nl]);
    89   }
    90   putchar('\n');
    91 }
    92 /* ------------------------------------------------------------------------------------------------------------------ */
    93 IMAGE_EXPORT(void) display_si16vector_circular_number(sint16 *v,long nl,long nh, long c0, long c1, char *format, char *name)
    94 /* ------------------------------------------------------------------------------------------------------------------ */
    95 {
    96   long i, n=nh-nl+1;
    97 
    98   if(name != NULL) puts(name);
    99 
    100   putchar('#'); for(i=c0; i<=c1; i++) { printf(format,   i%n+nl); } putchar('\n');
    101   putchar(' ');  for(i=c0; i<=c1; i++) { printf(format, v[i%n+nl]);} putchar('\n');
    102 }
    103 /* ---------------------------------------------------------------------------------------------------------------- */
    104 IMAGE_EXPORT(void) display_ui32vector_circular_number(uint32 *v,long nl,long nh, long c0, long c1, char *format, char *name)
    105 /* ---------------------------------------------------------------------------------------------------------------- */
    106 {
    107   long i, n=nh-nl+1;
    108 
    109   if(name != NULL) puts(name);
    110 
    111   putchar('#'); for(i=c0; i<=c1; i++) { printf(format,   i%n+nl); } putchar('\n');
    112   putchar(' '); for(i=c0; i<=c1; i++) { printf(format, v[i%n+nl]);} putchar('\n');
    113 }
    114 /* ----------------------------------------------------------------------------------------------------------------- */
    115 IMAGE_EXPORT(void) display_f32vector_circular_number(float32 *v,long nl,long nh, long c0, long c1, char *format, char *name)
    116 /* ----------------------------------------------------------------------------------------------------------------- */
    117 {
    118   long i, n=nh-nl+1;
    119 
    120   if(name != NULL) puts(name);
    121 
    122   putchar('#'); for(i=c0; i<=c1; i++) { printf(format,   i%n+nl); } putchar('\n');
    123   putchar(' ');  for(i=c0; i<=c1; i++) { printf(format, v[i%n+nl]);} putchar('\n');
    124 }
    125 /* ------------------------------------------------------------------------------------------------------------------- */
    126 IMAGE_EXPORT(void) display_dvector_circular_number(float64 *v,long nl,long nh, long c0, long c1, char *format, char *name)
    127 /* ------------------------------------------------------------------------------------------------------------------- */
    128 {
    129   long i, n=nh-nl+1;
    130 
    131   if(name != NULL) puts(name);
    132 
    133   putchar('#'); for(i=c0; i<=c1; i++) { printf(format,   i%n+nl); } putchar('\n');
    134   putchar(' '); for(i=c0; i<=c1; i++) { printf(format, v[i%n+nl]);} putchar('\n');
     23#undef display_type_vector_circular
     24#define display_type_vector_circular(t) \
     25void short_name(t,display_,vector_circular)(t * v, int32_t nl, int32_t nh, int32_t c0, int32_t c1, char * format, char * name) \
     26{                                        \
     27    int32_t n = nh - nl + 1;             \
     28    if (name != NULL) {                  \
     29        printf("%s\n", name);            \
     30    }                                    \
     31    for (int32_t i = c0; i <= c1; i++) { \
     32        printf(format, v[i % n + nl]);   \
     33    }                                    \
     34    printf("\n");                        \
    13535}
    13636
    137 /* ------------------------------------------------------------------------------------- */
    138 IMAGE_EXPORT(void) display_bvector_cycle(byte *v,long nl,long nh, char *format, char *name)
    139 /* ------------------------------------------------------------------------------------- */
    140 {
    141   long i;
    142   uint8 first, next;
    143   uint8 *displayed;
    14437
    145   if(name != NULL) printf("%s", name);
     38display_type_vector_circular(int8_t);
     39display_type_vector_circular(uint8_t);
     40display_type_vector_circular(int16_t);
     41display_type_vector_circular(uint16_t);
     42display_type_vector_circular(int32_t);
     43display_type_vector_circular(uint32_t);
     44display_type_vector_circular(int64_t);
     45display_type_vector_circular(uint64_t);
     46display_type_vector_circular(float);
     47display_type_vector_circular(double);
    14648
    147   displayed = ui8vector0(nl, nh);
    148  
    149   for(i=nl; i<=nh; i++) {
    150     if(!displayed[i]) {
    151       displayed[i] = 1;
    152       printf(format, i);
    153       first = (byte) i;
    154       next = v[i];
    155       while(first != next) {
    156         displayed[next] = 1;
    157         printf(format, next);
    158         next = v[next];
    159       }
    160       putchar('\n');
    161     }
    162   }
    163   putchar('\n');
    164   free_ui8vector(displayed, nl, nh);
     49
     50
     51#undef display_type_vector_circular_number
     52#define display_type_vector_circular_number(t) \
     53void short_name(t,display_,vector_circular_number)(t * v, int32_t nl, int32_t nh, int32_t c0, int32_t c1, char * format, char * name) \
     54{                                        \
     55    int32_t n = nh - nl + 1;             \
     56    if (name != NULL) {                  \
     57        printf("%s", name);              \
     58    }                                    \
     59    printf("#");                         \
     60    for (int32_t i = c0; i <= c1; i++) { \
     61        printf(format, i % n + nl);      \
     62    }                                    \
     63    printf("\n ");                       \
     64    for (int32_t i = c0; i <= c1; i++) { \
     65        printf(format, v[i % n + nl]);   \
     66    }                                    \
     67    printf("\n");                        \
    16568}
    166 /* -------------------------------------------------------------------------------------- */
    167 IMAGE_EXPORT(void) display_si16vector_cycle(sint16 *v,long nl,long nh, char *format, char *name)
    168 /* -------------------------------------------------------------------------------------- */
    169 {
    170   long i;
    171   uint16 first, next;
    172   uint8 *displayed;
    17369
    174   if(name != NULL) printf("%s", name);
    17570
    176   displayed = ui8vector0(nl, nh);
    177  
    178   for(i=nl; i<=nh; i++) {
    179     if(!displayed[i]) {
    180       displayed[i] = 1;
    181       printf(format, i);
    182       first = (sint16) i;
    183       next = v[i];
    184       while(first != next) {
    185         displayed[next] = 1;
    186         printf(format, next);
    187         next = v[next];
    188       }
    189       putchar('\n');
    190     }
    191   }
    192   putchar('\n');
    193   free_ui8vector(displayed, nl, nh);
     71display_type_vector_circular_number(int8_t);
     72display_type_vector_circular_number(uint8_t);
     73display_type_vector_circular_number(int16_t);
     74display_type_vector_circular_number(uint16_t);
     75display_type_vector_circular_number(int32_t);
     76display_type_vector_circular_number(uint32_t);
     77display_type_vector_circular_number(int64_t);
     78display_type_vector_circular_number(uint64_t);
     79display_type_vector_circular_number(float);
     80display_type_vector_circular_number(double);
     81
     82
     83
     84#undef display_type_vector_cycle
     85#define display_type_vector_cycle(t) \
     86void short_name(t,display_,vector_cycle)(t * v, int32_t nl, int32_t nh, char * format, char * name) \
     87{                                        \
     88    uint8_t first;                       \
     89    uint8_t next;                        \
     90    uint8_t * displayed;                 \
     91                                         \
     92    if (name != NULL) {                  \
     93        printf("%s", name);              \
     94    }                                    \
     95    displayed = ui8vector0(nl, nh);      \
     96    for (int32_t i = nl; i <= nh; i++) { \
     97        if (!displayed[i]) {             \
     98            displayed[i] = 1;            \
     99            printf(format, i);           \
     100            first = (t) i;               \
     101            next = v[i];                 \
     102            while (first != next) {      \
     103                displayed[next] = 1;     \
     104                printf(format, next);    \
     105                next = v[next];          \
     106            }                            \
     107            printf("\n");                \
     108        }                                \
     109    }                                    \
     110    printf("\n");                        \
     111    free_ui8vector(displayed, nl, nh);   \
    194112}
    195 /* ---------------------------------------------------------------------------------------- */
    196 IMAGE_EXPORT(void) display_ui16vector_cycle(uint16 *v,long nl,long nh, char *format, char *name)
    197 /* ---------------------------------------------------------------------------------------- */
    198 {
    199   long i;
    200   uint16 first, next;
    201   uint8 *displayed;
    202113
    203   if(name != NULL) printf("%s", name);
    204114
    205   displayed = ui8vector0(nl, nh);
    206  
    207   for(i=nl; i<=nh; i++) {
    208     if(!displayed[i]) {
    209       displayed[i] = 1;
    210       printf(format, i);
    211       first = (uint16) i;
    212       next = v[i];
    213       while(first != next) {
    214         displayed[next] = 1;
    215         printf(format, next);
    216         next = v[next];
    217       }
    218       putchar('\n');
    219     }
    220   }
    221   putchar('\n');
    222   free_ui8vector(displayed, nl, nh);
    223 }
     115display_type_vector_cycle(int8_t);
     116display_type_vector_cycle(uint8_t);
     117display_type_vector_cycle(int16_t);
     118display_type_vector_cycle(uint16_t);
     119display_type_vector_cycle(int32_t);
     120display_type_vector_cycle(uint32_t);
     121display_type_vector_cycle(int64_t);
     122display_type_vector_cycle(uint64_t);
     123display_type_vector_cycle(float);
     124display_type_vector_cycle(double);
     125
     126
     127// Local Variables:
     128// tab-width: 4
     129// c-basic-offset: 4
     130// c-file-offsets:((innamespace . 0)(inline-open . 0))
     131// indent-tabs-mode: nil
     132// End:
     133
     134// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=4:softtabstop=4
     135
Note: See TracChangeset for help on using the changeset viewer.