source: soft/giet_vm/applications/rosenfeld/nrc2/src/nrbool2.c @ 823

Last change on this file since 823 was 822, checked in by meunier, 8 years ago

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 size: 5.7 KB
Line 
1/* ----------------- */
2/* --- nrbool2.c --- */
3/* ----------------- */
4
5/*
6 * Copyright (c) 2000-2014, Lionel Lacassagne, All rights reserved
7 * Univ Paris Sud XI, CNRS
8 *
9 * Distributed under the Boost Software License, Version 1.0
10 * see accompanying file LICENSE.txt or copy it at
11 * http://www.boost.org/LICENSE_1_0.txt
12 */
13
14
15#include <stdio.h>
16#include <stddef.h>
17#include <stdlib.h>
18#include <math.h>
19#include <stdbool.h>
20
21#include "nrc_os_config.h"
22#include "mypredef.h"
23#include "nrtype.h"
24#include "nrdef.h"
25#include "nrmacro.h"
26#include "nrkernel.h"
27
28#include "nrbool1.h"
29#include "nrbool2.h"
30
31
32#undef cmpeq_type_matrix
33#define cmpeq_type_matrix(t) \
34int32_t short_name(t,cmpeq_,matrix)(t ** X, int32_t nrl, int32_t nrh, int32_t ncl, int32_t nch, t ** Y) \
35{                                              \
36    for (int32_t i = nrl; i <= nrh; i++) {     \
37        for (int32_t j = ncl; j <= nch; j++) { \
38            if (X[i][j] != Y[i][j]) {          \
39                return 1;                      \
40            }                                  \
41        }                                      \
42    }                                          \
43    return 0;                                  \
44}
45
46cmpeq_type_matrix(int8_t);
47cmpeq_type_matrix(uint8_t);
48cmpeq_type_matrix(int16_t);
49cmpeq_type_matrix(uint16_t);
50cmpeq_type_matrix(int32_t);
51cmpeq_type_matrix(uint32_t);
52cmpeq_type_matrix(int64_t);
53cmpeq_type_matrix(uint64_t);
54
55
56
57/*
58 * -----------
59 * --- Not ---
60 * -----------
61 */
62
63#undef not_type_matrix
64#define not_type_matrix(t) \
65void short_name(t,not_,matrix)(t ** X, int32_t nrl, int32_t nrh, int32_t ncl, int32_t nch, t ** Y) \
66{                                                        \
67    for (int32_t i = nrl; i <= nrh; i++) {               \
68        short_name(t,not_,vector)(X[i], ncl, nch, Y[i]); \
69    }                                                    \
70}
71
72not_type_matrix(int8_t);
73not_type_matrix(uint8_t);
74not_type_matrix(int16_t);
75not_type_matrix(uint16_t);
76not_type_matrix(int32_t);
77not_type_matrix(uint32_t);
78not_type_matrix(int64_t);
79not_type_matrix(uint64_t);
80not_type_matrix(rgb8);
81not_type_matrix(rgbx8);
82
83
84
85/*
86 * ----------
87 * --- Or ---
88 * ----------
89 */
90
91#undef or_type_matrix
92#define or_type_matrix(t) \
93void short_name(t,or_,matrix)(t ** X, int32_t nrl, int32_t nrh, int32_t ncl, int32_t nch, t ** Y, t ** Z) \
94{                                                             \
95    for (int32_t i = nrl; i <= nrh; i++) {                    \
96        short_name(t,or_,vector)(X[i], ncl, nch, Y[i], Z[i]); \
97    }                                                         \
98}                                                             \
99void short_name(t,orc_,matrix)(t ** X, int32_t nrl, int32_t nrh, int32_t ncl, int32_t nch, t y, t ** Z) \
100{                                                             \
101    for (int32_t i = nrl; i <= nrh; i++) {                    \
102        short_name(t,orc_,vector)(X[i], ncl, nch, y, Z[i]);   \
103    }                                                         \
104}
105
106or_type_matrix(int8_t);
107or_type_matrix(uint8_t);
108or_type_matrix(int16_t);
109or_type_matrix(uint16_t);
110or_type_matrix(int32_t);
111or_type_matrix(uint32_t);
112or_type_matrix(int64_t);
113or_type_matrix(uint64_t);
114or_type_matrix(rgb8);
115or_type_matrix(rgbx8);
116
117
118/*
119 * -----------
120 * --- Xor ---
121 * -----------
122 */
123
124#undef xor_type_matrix
125#define xor_type_matrix(t) \
126void short_name(t,xor_,matrix)(t ** X, int32_t nrl, int32_t nrh, int32_t ncl, int32_t nch, t ** Y, t ** Z) \
127{                                                              \
128    for (int32_t i = nrl; i <= nrh; i++) {                     \
129        short_name(t,xor_,vector)(X[i], ncl, nch, Y[i], Z[i]); \
130    }                                                          \
131}                                                              \
132void short_name(t,xorc_,matrix)(t ** X, int32_t nrl, int32_t nrh, int32_t ncl, int32_t nch, t y, t ** Z) \
133{                                                              \
134    for (int32_t i = nrl; i <= nrh; i++) {                     \
135        short_name(t,xorc_,vector)(X[i], ncl, nch, y, Z[i]);   \
136    }                                                          \
137}
138
139xor_type_matrix(int8_t);
140xor_type_matrix(uint8_t);
141xor_type_matrix(int16_t);
142xor_type_matrix(uint16_t);
143xor_type_matrix(int32_t);
144xor_type_matrix(uint32_t);
145xor_type_matrix(int64_t);
146xor_type_matrix(uint64_t);
147xor_type_matrix(rgb8);
148xor_type_matrix(rgbx8);
149
150
151/*
152 * ----------
153 * --- And ---
154 * ----------
155 */
156
157#undef and_type_matrix
158#define and_type_matrix(t) \
159void short_name(t,and_,matrix)(t ** X, int32_t nrl, int32_t nrh, int32_t ncl, int32_t nch, t ** Y, t ** Z) \
160{                                                              \
161    for (int32_t i = nrl; i <= nrh; i++) {                     \
162        short_name(t,and_,vector)(X[i], ncl, nch, Y[i], Z[i]); \
163    }                                                          \
164}                                                              \
165void short_name(t,andc_,matrix)(t ** X, int32_t nrl, int32_t nrh, int32_t ncl, int32_t nch, t y, t ** Z) \
166{                                                              \
167    for (int32_t i = nrl; i <= nrh; i++) {                     \
168        short_name(t,andc_,vector)(X[i], ncl, nch, y, Z[i]);   \
169    }                                                          \
170}
171
172and_type_matrix(int8_t);
173and_type_matrix(uint8_t);
174and_type_matrix(int16_t);
175and_type_matrix(uint16_t);
176and_type_matrix(int32_t);
177and_type_matrix(uint32_t);
178and_type_matrix(int64_t);
179and_type_matrix(uint64_t);
180and_type_matrix(rgb8);
181and_type_matrix(rgbx8);
182
183
184// Local Variables:
185// tab-width: 4
186// c-basic-offset: 4
187// c-file-offsets:((innamespace . 0)(inline-open . 0))
188// indent-tabs-mode: nil
189// End:
190
191// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=4:softtabstop=4
192
Note: See TracBrowser for help on using the repository browser.