Changeset: f7521838430f for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=f7521838430f
Modified Files:
gdk/gdk_aggr.c
Branch: Oct2014
Log Message:
Add some restrict qualifiers.
diffs (truncated from 362 to 300 lines):
diff --git a/gdk/gdk_aggr.c b/gdk/gdk_aggr.c
--- a/gdk/gdk_aggr.c
+++ b/gdk/gdk_aggr.c
@@ -156,7 +156,7 @@ BATgroupaggrinit(BAT *b, BAT *g, BAT *e,
#define AGGR_SUM(TYPE1, TYPE2) \
do { \
TYPE1 x; \
- const TYPE1 *vals = (const TYPE1 *) values; \
+ const TYPE1 *restrict vals = (const TYPE1 *) values; \
if (ngrp == 1 && cand == NULL) { \
/* single group, no candidate list */ \
TYPE2 sum; \
@@ -305,16 +305,16 @@ BATgroupaggrinit(BAT *b, BAT *g, BAT *e,
} while (0)
static BUN
-dosum(const void *values, int nonil, oid seqb, BUN start, BUN end,
- void *results, BUN ngrp, int tp1, int tp2,
- const oid *cand, const oid *candend, const oid *gids,
+dosum(const void *restrict values, int nonil, oid seqb, BUN start, BUN end,
+ void *restrict results, BUN ngrp, int tp1, int tp2,
+ const oid *restrict cand, const oid *candend, const oid *restrict gids,
oid min, oid max, int skip_nils, int abort_on_error,
int nil_if_empty, const char *func)
{
BUN nils = 0;
BUN i;
oid gid;
- unsigned int *seen; /* bitmask for groups that we've seen */
+ unsigned int *restrict seen; /* bitmask for groups that we've seen */
/* allocate bitmap for seen group ids */
seen = GDKzalloc(((ngrp + 31) / 32) * sizeof(int));
@@ -325,7 +325,7 @@ dosum(const void *values, int nonil, oid
switch (tp2) {
case TYPE_bte: {
- bte *sums = (bte *) results;
+ bte *restrict sums = (bte *) results;
switch (tp1) {
case TYPE_bte:
AGGR_SUM(bte, bte);
@@ -336,7 +336,7 @@ dosum(const void *values, int nonil, oid
break;
}
case TYPE_sht: {
- sht *sums = (sht *) results;
+ sht *restrict sums = (sht *) results;
switch (tp1) {
case TYPE_bte:
AGGR_SUM(bte, sht);
@@ -353,7 +353,7 @@ dosum(const void *values, int nonil, oid
case TYPE_wrd:
#endif
case TYPE_int: {
- int *sums = (int *) results;
+ int *restrict sums = (int *) results;
switch (tp1) {
case TYPE_bte:
AGGR_SUM(bte, int);
@@ -376,7 +376,7 @@ dosum(const void *values, int nonil, oid
case TYPE_wrd:
#endif
case TYPE_lng: {
- lng *sums = (lng *) results;
+ lng *restrict sums = (lng *) results;
switch (tp1) {
case TYPE_bte:
AGGR_SUM(bte, lng);
@@ -402,7 +402,7 @@ dosum(const void *values, int nonil, oid
break;
}
case TYPE_flt: {
- flt *sums = (flt *) results;
+ flt *restrict sums = (flt *) results;
switch (tp1) {
case TYPE_flt:
AGGR_SUM(flt, flt);
@@ -413,7 +413,7 @@ dosum(const void *values, int nonil, oid
break;
}
case TYPE_dbl: {
- dbl *sums = (dbl *) results;
+ dbl *restrict sums = (dbl *) results;
switch (tp1) {
case TYPE_flt:
AGGR_SUM(flt, dbl);
@@ -649,7 +649,7 @@ BATsum(void *res, int tp, BAT *b, BAT *s
#define AGGR_PROD(TYPE1, TYPE2, TYPE3) \
do { \
- const TYPE1 *vals = (const TYPE1 *) values; \
+ const TYPE1 *restrict vals = (const TYPE1 *) values; \
assert(gidincr == 0 || gidincr == 1); \
gid = 0; /* doesn't change if gidincr == 0 */ \
for (;;) { \
@@ -698,7 +698,7 @@ BATsum(void *res, int tp, BAT *b, BAT *s
#define AGGR_PROD_LNG(TYPE) \
do { \
- const TYPE *vals = (const TYPE *) values; \
+ const TYPE *restrict vals = (const TYPE *) values; \
assert(gidincr == 0 || gidincr == 1); \
gid = 0; /* doesn't change if gidincr == 0 */ \
for (;;) { \
@@ -746,7 +746,7 @@ BATsum(void *res, int tp, BAT *b, BAT *s
#define AGGR_PROD_FLOAT(TYPE1, TYPE2) \
do { \
- const TYPE1 *vals = (const TYPE1 *) values; \
+ const TYPE1 *restrict vals = (const TYPE1 *) values; \
assert(gidincr == 0 || gidincr == 1); \
gid = 0; /* doesn't change if gidincr == 0 */ \
for (;;) { \
@@ -797,15 +797,15 @@ BATsum(void *res, int tp, BAT *b, BAT *s
} while (0)
static BUN
-doprod(const void *values, oid seqb, BUN start, BUN end, void *results,
- BUN ngrp, int tp1, int tp2, const oid *cand, const oid *candend,
- const oid *gids, int gidincr, oid min, oid max,
+doprod(const void *restrict values, oid seqb, BUN start, BUN end, void
*restrict results,
+ BUN ngrp, int tp1, int tp2, const oid *restrict cand, const oid
*candend,
+ const oid *restrict gids, int gidincr, oid min, oid max,
int skip_nils, int abort_on_error, int nil_if_empty, const char *func)
{
BUN nils = 0;
BUN i;
oid gid;
- unsigned int *seen; /* bitmask for groups that we've seen */
+ unsigned int *restrict seen; /* bitmask for groups that we've seen */
/* allocate bitmap for seen group ids */
seen = GDKzalloc(((ngrp + 31) / 32) * sizeof(int));
@@ -816,7 +816,7 @@ doprod(const void *values, oid seqb, BUN
switch (tp2) {
case TYPE_bte: {
- bte *prods = (bte *) results;
+ bte *restrict prods = (bte *) results;
switch (tp1) {
case TYPE_bte:
AGGR_PROD(bte, bte, sht);
@@ -827,7 +827,7 @@ doprod(const void *values, oid seqb, BUN
break;
}
case TYPE_sht: {
- sht *prods = (sht *) results;
+ sht *restrict prods = (sht *) results;
switch (tp1) {
case TYPE_bte:
AGGR_PROD(bte, sht, int);
@@ -844,7 +844,7 @@ doprod(const void *values, oid seqb, BUN
case TYPE_wrd:
#endif
case TYPE_int: {
- int *prods = (int *) results;
+ int *restrict prods = (int *) results;
switch (tp1) {
case TYPE_bte:
AGGR_PROD(bte, int, lng);
@@ -867,7 +867,7 @@ doprod(const void *values, oid seqb, BUN
case TYPE_wrd:
#endif
case TYPE_lng: {
- lng *prods = (lng *) results;
+ lng *restrict prods = (lng *) results;
switch (tp1) {
case TYPE_bte:
AGGR_PROD_LNG(bte);
@@ -893,7 +893,7 @@ doprod(const void *values, oid seqb, BUN
break;
}
case TYPE_flt: {
- flt *prods = (flt *) results;
+ flt *restrict prods = (flt *) results;
switch (tp1) {
case TYPE_bte:
AGGR_PROD_FLOAT(bte, flt);
@@ -922,7 +922,7 @@ doprod(const void *values, oid seqb, BUN
break;
}
case TYPE_dbl: {
- dbl *prods = (dbl *) results;
+ dbl *restrict prods = (dbl *) results;
switch (tp1) {
case TYPE_bte:
AGGR_PROD_FLOAT(bte, dbl);
@@ -991,7 +991,7 @@ doprod(const void *values, oid seqb, BUN
BAT *
BATgroupprod(BAT *b, BAT *g, BAT *e, BAT *s, int tp, int skip_nils, int
abort_on_error)
{
- const oid *gids;
+ const oid *restrict gids;
oid min, max;
BUN ngrp;
BUN nils;
@@ -1176,8 +1176,8 @@ BATprod(void *res, int tp, BAT *b, BAT *
#define AGGR_AVG(TYPE) \
do { \
- const TYPE *vals = (const TYPE *) Tloc(b, BUNfirst(b)); \
- TYPE *avgs = GDKzalloc(ngrp * sizeof(TYPE)); \
+ const TYPE *restrict vals = (const TYPE *) Tloc(b,
BUNfirst(b)); \
+ TYPE *restrict avgs = GDKzalloc(ngrp * sizeof(TYPE)); \
if (avgs == NULL) \
goto alloc_fail; \
for (;;) { \
@@ -1223,7 +1223,7 @@ BATprod(void *res, int tp, BAT *b, BAT *
#define AGGR_AVG_FLOAT(TYPE) \
do { \
- const TYPE *vals = (const TYPE *) Tloc(b, BUNfirst(b)); \
+ const TYPE *restrict vals = (const TYPE *) Tloc(b,
BUNfirst(b)); \
for (i = 0; i < ngrp; i++) \
dbls[i] = 0; \
for (;;) { \
@@ -1267,14 +1267,14 @@ BATprod(void *res, int tp, BAT *b, BAT *
gdk_return
BATgroupavg(BAT **bnp, BAT **cntsp, BAT *b, BAT *g, BAT *e, BAT *s, int tp,
int skip_nils, int abort_on_error)
{
- const oid *gids;
+ const oid *restrict gids;
oid gid;
oid min, max;
BUN i, ngrp;
BUN nils = 0;
- BUN *rems = NULL;
- wrd *cnts = NULL;
- dbl *dbls;
+ BUN *restrict rems = NULL;
+ wrd *restrict cnts = NULL;
+ dbl *restrict dbls;
BAT *bn = NULL;
BUN start, end, cnt;
const oid *cand = NULL, *candend = NULL;
@@ -1542,7 +1542,7 @@ BATcalcavg(BAT *b, BAT *s, dbl *avg, BUN
lng sum = 0;
BUN start, end, cnt;
const oid *cand = NULL, *candend = NULL;
- const void *src;
+ const void *restrict src;
/* these two needed for ADD_WITH_CHECK macro */
int abort_on_error = 1;
BUN nils = 0;
@@ -1585,7 +1585,7 @@ BATcalcavg(BAT *b, BAT *s, dbl *avg, BUN
#define AGGR_COUNT(TYPE) \
do { \
- const TYPE *vals = (const TYPE *) Tloc(b, BUNfirst(b)); \
+ const TYPE *restrict vals = (const TYPE *) Tloc(b,
BUNfirst(b)); \
for (;;) { \
if (cand) { \
if (cand == candend) \
@@ -1615,11 +1615,11 @@ BATcalcavg(BAT *b, BAT *s, dbl *avg, BUN
BAT *
BATgroupcount(BAT *b, BAT *g, BAT *e, BAT *s, int tp, int skip_nils, int
abort_on_error)
{
- const oid *gids;
+ const oid *restrict gids;
oid gid;
oid min, max;
BUN i, ngrp;
- wrd *cnts;
+ wrd *restrict cnts;
BAT *bn = NULL;
int t;
const void *nil;
@@ -1734,11 +1734,11 @@ BATgroupcount(BAT *b, BAT *g, BAT *e, BA
BAT *
BATgroupsize(BAT *b, BAT *g, BAT *e, BAT *s, int tp, int skip_nils, int
abort_on_error)
{
- const oid *gids;
+ const oid *restrict gids;
oid min, max;
BUN i, ngrp;
- const bit *bits;
- wrd *cnts;
+ const bit *restrict bits;
+ wrd *restrict cnts;
BAT *bn = NULL;
BUN start, end, cnt;
const oid *cand = NULL, *candend = NULL;
@@ -1815,7 +1815,7 @@ BATgroupsize(BAT *b, BAT *g, BAT *e, BAT
#define AGGR_CMP(TYPE, OP) \
do { \
- const TYPE *vals = (const TYPE *) Tloc(b, BUNfirst(b)); \
+ const TYPE *restrict vals = (const TYPE *) Tloc(b,
BUNfirst(b)); \
if (ngrp == cnt) { \
/* single element groups */ \
if (cand) { \
@@ -1873,10 +1873,10 @@ BATgroupsize(BAT *b, BAT *g, BAT *e, BAT
static BAT *
BATgroupminmax(BAT *b, BAT *g, BAT *e, BAT *s, int tp, int skip_nils, int
abort_on_error, BUN (*minmax)(oid *, BAT *, const oid *, BUN, oid, oid, BUN,
BUN, const oid *, const oid *, BUN, int, int), const char *name)
{
- const oid *gids;
+ const oid *restrict gids;
oid min, max;
BUN ngrp;
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list