Changeset: 2dbea92e4786 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=2dbea92e4786
Added Files:
monetdb5/modules/kernel/array.c
monetdb5/modules/kernel/array.h
monetdb5/modules/kernel/array.mal
monetdb5/modules/kernel/mmath.c
monetdb5/modules/kernel/mmath.h
monetdb5/modules/kernel/mmath.mal
Removed Files:
monetdb5/modules/kernel/array.mx
monetdb5/modules/kernel/mmath.mx
Modified Files:
monetdb5/modules/kernel/Makefile.ag
monetdb5/modules/kernel/bat5.mal
monetdb5/tests/gdkTests/Tests/append_dense_tail.mal
monetdb5/tests/gdkTests/Tests/append_dense_tail.stable.out
monetdb5/tests/gdkTests/Tests/void.mal
monetdb5/tests/gdkTests/Tests/void.stable.out
Branch: default
Log Message:
De-Mx array and mmath modules
diffs (truncated from 1804 to 300 lines):
diff --git a/monetdb5/modules/kernel/Makefile.ag
b/monetdb5/modules/kernel/Makefile.ag
--- a/monetdb5/modules/kernel/Makefile.ag
+++ b/monetdb5/modules/kernel/Makefile.ag
@@ -40,7 +40,7 @@ lib_kernel = {
aggr.mx \
alarm.c alarm.h \
algebra.mx \
- array.mx \
+ array.c array.h \
bat5.c bat5.h \
batcalc.c \
batcolor.mx \
@@ -54,7 +54,7 @@ lib_kernel = {
lock.c lock.h \
logger.c \
microbenchmark.c microbenchmark.h \
- mmath.mx \
+ mmath.c mmath.h \
sema.c \
status.c status.h \
unix.c
@@ -64,9 +64,9 @@ headers_mal = {
HEADERS = mal
DIR = libdir/monetdb5
SOURCES = calc.mal bat5.mal algebra.mx status.mal unix.mal \
- mmath.mx lock.mal sema.mal alarm.mal batstr.mx batmtime.mx \
+ mmath.mal lock.mal sema.mal alarm.mal batstr.mx batmtime.mx \
batcolor.mx batifthen.mx batcalc.mal batmmath.mx \
- group.mx aggr.mx array.mx \
+ group.mx aggr.mx array.mal \
counters.mal logger.mal microbenchmark.mal
}
diff --git a/monetdb5/modules/kernel/array.mx b/monetdb5/modules/kernel/array.c
rename from monetdb5/modules/kernel/array.mx
rename to monetdb5/modules/kernel/array.c
--- a/monetdb5/modules/kernel/array.mx
+++ b/monetdb5/modules/kernel/array.c
@@ -1,28 +1,24 @@
-@/
-The contents of this file are subject to the MonetDB Public License
-Version 1.1 (the "License"); you may not use this file except in
-compliance with the License. You may obtain a copy of the License at
-http://www.monetdb.org/Legal/MonetDBLicense
-
-Software distributed under the License is distributed on an "AS IS"
-basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
-License for the specific language governing rights and limitations
-under the License.
-
-The Original Code is the MonetDB Database System.
-
-The Initial Developer of the Original Code is CWI.
-Portions created by CWI are Copyright (C) 1997-July 2008 CWI.
-Copyright August 2008-2012 MonetDB B.V.
-All Rights Reserved.
-@
-
-@f array
-
-@c
/*
- * @a A.R. van Ballegooij
- * @+ Basic array support
+ * The contents of this file are subject to the MonetDB Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * http://www.monetdb.org/Legal/MonetDBLicense
+ *
+ * Software distributed under the License is distributed on an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+ * License for the specific language governing rights and limitations
+ * under the License.
+ *
+ * The Original Code is the MonetDB Database System.
+ *
+ * The Initial Developer of the Original Code is CWI.
+ * Portions created by CWI are Copyright (C) 1997-July 2008 CWI.
+ * Copyright August 2008-2012 MonetDB B.V.
+ * All Rights Reserved.
+*/
+/*
+ * A.R. van Ballegooij
+ * Basic array support
*
* The array support library constructs the index arrays essential
* for the Relational Algebra Model language.
@@ -33,63 +29,6 @@ All Rights Reserved.
*
* The optimization is captured in a contraction macro.
*/
-@mal
-module array;
-@= grid_mdefs
-command grid(i:@1,j:@1,k:@1,l:@1) :bat[:oid,:@1]
-address ARRAYgrid_@1
-comment "Generates an index BAT, (grpcount,grpsize,clustersize,offset)";
-
-command grid(i:@1,j:@1,k:@1,l:@1,s:@1) :bat[:oid,:@1]
-address ARRAYgridShift_@1
-comment "Generates an index BAT, (grpcount,grpsize,clustersize,offset)
-and shift all elements with a factor s";
-
-command grid(b:bat[:oid,:@1],i:@1,j:@1,k:@1,l:@1) :bat[:oid,:@1]
-address ARRAYgridBAT_@1
-comment "Fills an index BAT, (grpcount,grpsize,clustersize,offset)";
-
-command grid(b:bat[:oid,:@1],i:@1,j:@1,k:@1,l:@1,s:@1) :bat[:oid,:@1]
-address ARRAYgridBATshift_@1
-comment "Fills an index BAT, (grpcount,grpsize,clustersize,offset)
-and shift all elemenets with a factor s";
-
-@
-@mal
-@:grid_mdefs(int)@
-@:grid_mdefs(lng)@
-
-command product(b:bat[:any_3,:any_1],c:bat[:any_4,:any_2]):bat[:any_1,:any_2]
-address ARRAYproduct
-comment "Produce an array product";
-
-command project(b:bat[:oid,:any_1],i:int):bat[:oid,:int]
-address ARRAYproject
-comment "Fill an array representation with constants ";
-
-# @- Implementation
-@c
-/*============================================================================*/
-#include "monetdb_config.h"
-#include "gdk.h"
-#include "algebra.h"
-#include <math.h>
-#include <time.h>
-
-/*----------------------------------------------------------------------------*/
-
-#ifdef WIN32
-#if !defined(LIBMAL) && !defined(LIBATOMS) && !defined(LIBKERNEL) &&
!defined(LIBMAL) && !defined(LIBOPTIMIZER) && !defined(LIBSCHEDULER) &&
!defined(LIBMONETDB5)
-#define array_export extern __declspec(dllimport)
-#else
-#define array_export extern __declspec(dllexport)
-#endif
-#else
-#define array_export extern
-#endif
-
-array_export str ARRAYproduct(int *ret, int *bid, int *rid);
-array_export str ARRAYproject(int *ret, int *bid, int *cst);
#define new_bat(b, s, TYPE)
\
do {
\
@@ -107,33 +46,27 @@ array_export str ARRAYproject(int *ret,
} while (0)
#define get_ptr(b,TYPE) ((TYPE*)(Tloc(b,BUNfirst((b)))))
-@= grid_impl
-array_export str ARRAYgrid_@1(@1 *ret, @1 *groups, @1 *groupsize, @1
*clustersize, @1 *offset);
-array_export str ARRAYgridShift_@1(@1 *ret, @1 *groups, @1 *groupsize, @1
*clustersize, @1 *offset, @1 *shift);
-array_export str ARRAYgridBAT_@1(@1 *ret, @1 *bid, @1 *groups, @1 *groupsize,
@1 *clustersize, @1 *offset);
-array_export str ARRAYgridBATshift_@1(@1 *ret, @1 *bid, @1 *groups, @1
*groupsize, @1 *clustersize, @1 *offset, @1 *shift);
-
static int
-fillgrid_@1(BAT **out, @1 *groups, @1 *groupsize, @1 *clustersize, @1 *offset,
@1 *shift)
+fillgrid_int(BAT **out, int *groups, int *groupsize, int *clustersize, int
*offset, int *shift)
{
- register @1 *ptr;
- @1 i = *groups;
- @1 n = *groupsize + *offset;
- @1 r = *clustersize;
- @1 o = *offset;
- @1 s = *shift;
+ register int *ptr;
+ int i = *groups;
+ int n = *groupsize + *offset;
+ int r = *clustersize;
+ int o = *offset;
+ int s = *shift;
#ifdef EXCESSIVE_DEBUGGING
fprintf(stderr, "[grid] (%d,%d,%d,%d)", i, n, r, o);
#endif
- ptr = get_ptr(*out, @1);
+ ptr = get_ptr(*out, int);
while (i--) {
- register @1 ni = o;
+ register int ni = o;
while (ni < n) {
- register @1 ri = r;
+ register int ri = r;
while (ri--)
(*(ptr ++)) = ni * s;
@@ -149,63 +82,128 @@ fillgrid_@1(BAT **out, @1 *groups, @1 *g
}
static int
-grid_@1(BAT **out, @1 *groups, @1 *groupsize, @1 *clustersize, @1 *offset)
+grid_int(BAT **out, int *groups, int *groupsize, int *clustersize, int *offset)
{
- @1 i = *groups;
- @1 n = *groupsize + *offset;
- @1 r = *clustersize;
- @1 o = *offset;
- @1 s = 1;
+ int i = *groups;
+ int n = *groupsize + *offset;
+ int r = *clustersize;
+ int o = *offset;
+ int s = 1;
#ifdef EXCESSIVE_DEBUGGING
fprintf(stderr, "[grid] (%d,%d,%d,%d)", i, n, r, o);
#endif
- new_bat(*out, (i * (n - o) * r), @1);
+ new_bat(*out, (i * (n - o) * r), int);
if (out == NULL) {
- GDKerror("grid: cannot create the bat (" @2 " BUNs)\n", (i * (n
- o) * r));
+ GDKerror("grid: cannot create the bat (%d BUNs)\n", (i * (n -
o) * r));
return GDK_FAIL;
}
- add_vals(*out, (i * (n - o) * r), @1);
- return fillgrid_@1(out, groups, groupsize, clustersize, offset, &s);
+ add_vals(*out, (i * (n - o) * r), int);
+ return fillgrid_int(out, groups, groupsize, clustersize, offset, &s);
}
static int
-gridShift_@1(BAT **out, @1 *groups, @1 *groupsize, @1 *clustersize, @1
*offset, @1 *shift)
+gridShift_int(BAT **out, int *groups, int *groupsize, int *clustersize, int
*offset, int *shift)
{
- @1 i = *groups;
- @1 n = *groupsize + *offset;
- @1 r = *clustersize;
- @1 o = *offset;
+ int i = *groups;
+ int n = *groupsize + *offset;
+ int r = *clustersize;
+ int o = *offset;
#ifdef EXCESSIVE_DEBUGGING
fprintf(stderr, "[grid] (%d,%d,%d,%d)", i, n, r, o);
#endif
- new_bat(*out, (i * (n - o) * r), @1);
+ new_bat(*out, (i * (n - o) * r), int);
if (*out == 0)
return GDK_FAIL;
- add_vals(*out, (i * (n - o) * r), @1);
- return fillgrid_@1(out, groups, groupsize, clustersize, offset, shift);
+ add_vals(*out, (i * (n - o) * r), int);
+ return fillgrid_int(out, groups, groupsize, clustersize, offset, shift);
}
-@
-@c
-@:grid_impl(int,"%d")@
-@:grid_impl(lng,LLFMT)@
+static int
+fillgrid_lng(BAT **out, lng *groups, lng *groupsize, lng *clustersize, lng
*offset, lng *shift)
+{
+ register lng *ptr;
+ lng i = *groups;
+ lng n = *groupsize + *offset;
+ lng r = *clustersize;
+ lng o = *offset;
+ lng s = *shift;
-/*
- * @+
- * The M5 wrapper code
- */
-#include "mal.h"
-@= grid_wrapper_impl
+#ifdef EXCESSIVE_DEBUGGING
+ fprintf(stderr, "[grid] (%d,%d,%d,%d)", i, n, r, o);
+#endif
+
+ ptr = get_ptr(*out, lng);
+
+ while (i--) {
+ register lng ni = o;
+
+ while (ni < n) {
+ register lng ri = r;
+
+ while (ri--)
+ (*(ptr ++)) = ni * s;
+ ni++;
+ }
+ }
+
+#ifdef EXCESSIVE_DEBUGGING
+ fprintf(stderr, "- done\n");
+#endif
+
+ return GDK_SUCCEED;
_______________________________________________
Checkin-list mailing list
[email protected]
http://mail.monetdb.org/mailman/listinfo/checkin-list