Changeset: 3eae742086ba for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=3eae742086ba
Added Files:
monetdb5/extras/bwd/optimizer_utilities.c
monetdb5/extras/bwd/optimizer_utilities.h
monetdb5/extras/bwd/pusher.c
Modified Files:
monetdb5/extras/bwd/Makefile.ag
monetdb5/extras/bwd/bwd.c
monetdb5/extras/bwd/cl_program_utilities.c
monetdb5/extras/bwd/operations.c
monetdb5/extras/bwd/opt_bwd.mal
monetdb5/extras/bwd/optimizer.c
monetdb5/extras/bwd/utilities.c
monetdb5/extras/bwd/utilities.h
Branch: bwd
Log Message:
* started the pusher-optimizer (non-functional)
* lot's of little rewrites to make the compiler happy (stupid c90)
Unterschiede (gekürzt von 1854 auf 300 Zeilen):
diff --git a/monetdb5/extras/bwd/Makefile.ag b/monetdb5/extras/bwd/Makefile.ag
--- a/monetdb5/extras/bwd/Makefile.ag
+++ b/monetdb5/extras/bwd/Makefile.ag
@@ -38,7 +38,7 @@ lib_bwd = {
MODULE
DIR = libdir/monetdb5
SEP = _
- SOURCES = bwd.c optimizer.c operations.c utilities.c
cl_program_utilities.c
+ SOURCES = bwd.c optimizer.c optimizer_utilities.c pusher.c operations.c
utilities.c cl_program_utilities.c
LIBS = ../../tools/libmonetdb5 \
../../../gdk/libbat \
../../../common/stream/libstream \
diff --git a/monetdb5/extras/bwd/bwd.c b/monetdb5/extras/bwd/bwd.c
--- a/monetdb5/extras/bwd/bwd.c
+++ b/monetdb5/extras/bwd/bwd.c
@@ -1,5 +1,7 @@
#pragma GCC diagnostic ignored "-Wdeclaration-after-statement"
-
+#pragma GCC diagnostic ignored "-Wunused-parameter"
+#pragma GCC diagnostic ignored "-Wmissing-prototypes"
+
#include "monetdb_config.h"
#include "opt_statistics.h"
#include "bwd.h"
@@ -24,7 +26,7 @@
#define die(msg, args...) throw (MAL, "bwd", msg, args);
-char* clDeviceString(cl_device_type device_type){
+static char* clDeviceString(cl_device_type device_type){
switch(device_type){
case CL_DEVICE_TYPE_DEFAULT:
return "CL_DEVICE_TYPE_DEFAULT";
@@ -50,30 +52,31 @@ str deviceInfo(bat * resPlatform, bat *
{
cl_uint numPlatforms;
int err;
+ cl_platform_id* platforms;
+ uint i;
if((err = clGetPlatformIDs(0, NULL, &numPlatforms)))
die ("clGetPlatformIDs (getting platform count) error:
%s\n", clError(err));
- cl_platform_id* platforms =
malloc(sizeof(cl_platform_id)*numPlatforms);
+ platforms = malloc(sizeof(cl_platform_id)*numPlatforms);
if((err = clGetPlatformIDs(numPlatforms, platforms,
&numPlatforms)))
die ("clGetPlatformIDs error: %s\n",clError(err));
- int i;
for(i = 0; i<numPlatforms;i++){
cl_device_id devices[8];
cl_uint numberOfDevices = 0;
+ uint j;
clGetDeviceIDs(platforms[i],CL_DEVICE_TYPE_ALL,8,devices,&numberOfDevices);
- int j;
for (j = 0; j < numberOfDevices; ++j){
cl_device_type device_type;
char deviceNameBuffer[1024];
+ char* platformVersionBuffer;
{
+ cl_bool endianLittle;
+ char deviceName[1024];
clGetDeviceInfo(devices[j],CL_DEVICE_TYPE,sizeof(cl_ulong),&device_type,NULL);
- char deviceName[1024];
- cl_bool endianLittle;
if((err =
clGetDeviceInfo(devices[j],CL_DEVICE_NAME,sizeof(deviceName),&deviceName,NULL)))
die ("clGetDeviceInfo error: %s\n",clError(err));
if((err =
clGetDeviceInfo(devices[j],CL_DEVICE_ENDIAN_LITTLE,sizeof(cl_bool),&endianLittle,NULL)))
die ("clGetDeviceInfo error: %s\n",clError(err));
snprintf (deviceNameBuffer, 1024, "%d:
%s (%s), endianness: %s\n", j, deviceName, clDeviceString(device_type),
(str[]){[CL_TRUE] = "little", [CL_FALSE] = "big"}[endianLittle]);
}
- char* platformVersionBuffer;
{
size_t platformVersionBufferSize;
clGetPlatformInfo(platforms[i],
CL_PLATFORM_VERSION, 0, NULL, &platformVersionBufferSize);
@@ -99,11 +102,12 @@ str deviceInfo(bat * resPlatform, bat *
str bwdecompose(bat * res, bat * subjectBAT, int* approximationBits, Client
cntxt){
+ BAT* result;
+ char buffer[4096];
BAT* subject = BATdescriptor(*subjectBAT);
if (VIEWtparent(subject))
subject = BATdescriptor(abs(VIEWtparent(subject)));
- BAT* result = BATnew(TYPE_void, TYPE_str, 0);
- char buffer[4096];
+ result = BATnew(TYPE_void, TYPE_str, 0);
if(! batTailIsDecomposed(subject)){
printf ("decomposing %s into %d and %d bits\n",
resolveBatToAttribute(subject->batCacheid, cntxt), approximationBits[0],
Tsize(subject)*8-*approximationBits);
BATsetprop(subject, batRegistryIndex, TYPE_int,
(int[]){decomposeIntArray((int*)Tloc(subject, BUNfirst(subject)),
subject->batCount, *approximationBits)});
@@ -121,9 +125,9 @@ str bwdecompose(bat * res, bat * subject
char* resolveBatToAttribute(bat bid, Client cntxt){
mvc *m = NULL;
- str msg = getSQLContext(cntxt, NULL, &m, NULL);
sql_trans *tr = m->session->tr;
node *nsch, *ntab, *ncol;
+ char* buffer = malloc(32);
for( nsch= tr->schemas.set->h; nsch; nsch= nsch->next){
sql_base *b= nsch->data;
@@ -138,7 +142,6 @@ char* resolveBatToAttribute(bat bid, Cli
sql_base *bc =
ncol->data;
sql_column *c=
(sql_column *) ncol->data;
BAT *bn =
store_funcs.bind_col(tr, c, 0);
- lng sz;
if(bn->batCacheid == bid){
char*
buffer = malloc(strlen(bc->name) + strlen(bt->name)+15);
@@ -149,7 +152,6 @@ char* resolveBatToAttribute(bat bid, Cli
}
}
}
- char* buffer = malloc(32);
snprintf(buffer, 32, "%d", bid);
return buffer;
@@ -179,8 +181,9 @@ void releaseMemObject(cl_mem object, cha
}
void releaseCLMemObject(bat* subjectID){
+ BAT* subject;
if(0) printf ("releasing bat %d\n", *subjectID);
- BAT* subject = BBPquickdesc(*subjectID,0);
+ subject = BBPquickdesc(*subjectID,0);
if(!isPersistentBAT(subject)){
if(batHeadApproximation(subject))
releaseMemObject(batHeadApproximation(subject),
"batHeadApproximation", *subjectID);
@@ -191,7 +194,7 @@ void releaseCLMemObject(bat* subjectID){
}
}
-str bwdinit(){
+str bwdinit(void){
registerBBPDestroyCallback(releaseCLMemObject);
return MAL_SUCCEED;
}
diff --git a/monetdb5/extras/bwd/cl_program_utilities.c
b/monetdb5/extras/bwd/cl_program_utilities.c
--- a/monetdb5/extras/bwd/cl_program_utilities.c
+++ b/monetdb5/extras/bwd/cl_program_utilities.c
@@ -1,4 +1,6 @@
#pragma GCC diagnostic ignored "-Wdeclaration-after-statement"
+#pragma GCC diagnostic ignored "-Wunused-parameter"
+#pragma GCC diagnostic ignored "-Wmissing-prototypes"
#include "monetdb_config.h"
#include "opt_statistics.h"
@@ -24,22 +26,23 @@ char* approximateOperation(char* exactOp
static inline void superverboseprintf(const char * format, ... ){};
cl_program compileProgram(const char* sourceCode, char* options){
- struct timespec before, after;
- clock_gettime(CLOCK_THREAD_CPUTIME_ID, &before);
+ /* struct timespec before, after; */
+ /* clock_gettime(CLOCK_THREAD_CPUTIME_ID, &before); */
cl_int err;
cl_program program = clCreateProgramWithSource(getCLContext(), 1,
(const char*[]){sourceCode}, (size_t[]){strlen(sourceCode)}, &err);
if(err) THRprintf(GDKout, "#%s, clCreateProgramWithSource: %s;\n",
__func__, clError(err));
err = clBuildProgram(program, 1, (const cl_device_id[]){getDeviceID()},
options, NULL, NULL);
if(err) {
- printf("#%s, clBuildProgram: %s;\n", __func__, clError(err));
size_t bufferSize;
char* buffer;
+
+ printf("#%s, clBuildProgram: %s;\n", __func__, clError(err));
clGetProgramBuildInfo(program, getDeviceID(),
CL_PROGRAM_BUILD_LOG, 0, NULL, &bufferSize);
clGetProgramBuildInfo(program, getDeviceID(),
CL_PROGRAM_BUILD_LOG, bufferSize, (buffer = alloca(bufferSize)), NULL);
printf("#%s, clBuildProgram log: %s;\n", __func__, buffer);
}
- clock_gettime(CLOCK_THREAD_CPUTIME_ID, &after);
- printf ("compilation took %ld
nanoseconds\n",(after.tv_sec*1000000000+after.tv_nsec)-(before.tv_sec*1000000000+before.tv_nsec));
+ /* clock_gettime(CLOCK_THREAD_CPUTIME_ID, &after); */
+ /* printf ("compilation took %ld
nanoseconds\n",(after.tv_sec*1000000000+after.tv_nsec)-(before.tv_sec*1000000000+before.tv_nsec));
*/
return program;
}
@@ -186,7 +189,9 @@ cl_program getUSelectProgram(int type, c
};
char* sourceCode = malloc(16384);
snprintf(sourceCode, 16384, sourceCodeTemplates[inputIsVoidHeaded>0],
(str[]){[TYPE_int] = "int"}[type], approximateOperation(predicateOperation),
predicateOperation2?approximateOperation(predicateOperation2):"==",
approximationBits/8-offsetBits/8, predicateOperation2 == NULL?1:0,
offsetBits/8);
- cl_program program = compileProgram(sourceCode,"");
- free(sourceCode);
- return program;
+ {
+ cl_program program = compileProgram(sourceCode,"");
+ free(sourceCode);
+ return program;
+ }
}
diff --git a/monetdb5/extras/bwd/operations.c b/monetdb5/extras/bwd/operations.c
--- a/monetdb5/extras/bwd/operations.c
+++ b/monetdb5/extras/bwd/operations.c
@@ -1,4 +1,6 @@
#pragma GCC diagnostic ignored "-Wdeclaration-after-statement"
+#pragma GCC diagnostic ignored "-Wunused-parameter"
+#pragma GCC diagnostic ignored "-Wmissing-prototypes"
#include "monetdb_config.h"
#include "opt_statistics.h"
@@ -31,6 +33,7 @@ static const int CL_REFCOUNT_DEBUG = 0;
#pragma mark Actual MAL Operations Implementation
#ifdef __APPLE__
+void clock_gettime(int a, struct timespec* b);
void clock_gettime(int a, struct timespec* b){
b->tv_sec = 0;
b->tv_nsec = 0;
@@ -92,6 +95,7 @@ clTail* getApproximateValuesColumn(cl_me
}
str BWDLeftJoinApproximate(bat * res, bat * l, bat * r){
+ BAT* left;
BAT* right = BATdescriptor(*r);
if(!batTailIsDecomposed(right)){
printf("bwd.%s : bat is not decomposed: %d, no approximation
can be provided\n", __func__, *r);
@@ -99,23 +103,24 @@ str BWDLeftJoinApproximate(bat * res, ba
return MAL_SUCCEED;
}
- BAT* left = BATdescriptor(*l);
+ left = BATdescriptor(*l);
if(0) printf ("%s left bat (%d) is of type [%s%s, %s%s]\n", __func__,
left->batCacheid, typeNames[BAThtype(left)], BAThvoid(left)?" (void)":"",
typeNames[BATttype(left)], BATtvoid(left)?" (void)":"");
if(0 && BAThvoid(left) && BATtvoid(left) && BAThvoid(right) &&
right->tseqbase != oid_nil){
// the more I think about this, the more I feel this case can
never happen
+ uint i;
+ int* outputRegion;
+ const size_t offset = left->tseqbase;
+ const size_t approximationBytes =
batTailApproximationBits(right)/8;
+ const unsigned int residualBits =
32-batTailApproximationBits(right);
+ unsigned char* approximation =
malloc(left->batCount*approximationBytes);
BAT* result = BATnew(ATOMtype(left->htype),
ATOMtype(right->ttype), left->batCount);
+
BATsetcount(result, left->batCount);
bzero(Tloc(result, BUNfirst(result)),
left->batCount*sizeof(int));
- int i;
- int* outputRegion = (int*) Tloc(result, BUNfirst(result));
- const register size_t offset = left->tseqbase;
- const register size_t approximationBytes =
batTailApproximationBits(right)/8;
- const register unsigned int residualBits =
32-batTailApproximationBits(right);
+ outputRegion = (int*) Tloc(result, BUNfirst(result));
- void* approximation =
malloc(left->batCount*approximationBytes);
{
- const cl_mem approximationObject =
batTailApproximation(right);
clEnqueueReadBuffer(getCommandQueue(),
batTailApproximation(right), CL_TRUE, offset*approximationBytes,
left->batCount*approximationBytes, approximation, 0, NULL, NULL);
}
@@ -129,25 +134,30 @@ str BWDLeftJoinApproximate(bat * res, ba
BBPreleaseref(right->batCacheid);
return MAL_SUCCEED;
} else if(BAThvoid(left) && BAThvoid(right) && right->tseqbase !=
oid_nil){
+ cl_int err;
+ int headCount; // :-)
+ cl_kernel projectKernel;
+ cl_program program;
+ clTail newTailDefinition;
cl_mem leftColumn = batTailApproximation(left);
+ cl_mem rightColumn = batTailApproximation(right);
+ BAT* result;
+ int i;
if(!leftColumn) leftColumn =
batHeadApproximation(BATmirror(left));
- cl_mem rightColumn = batTailApproximation(right);
if(!rightColumn) rightColumn =
batHeadApproximation(BATmirror(right));
- cl_program program =
getProjectionLeftjoinProgram(batTailApproximationBits(right),
batTailOffsetBits(right));
+ program =
getProjectionLeftjoinProgram(batTailApproximationBits(right),
batTailOffsetBits(right));
- cl_int err;
- cl_kernel projectKernel = clCreateKernel(program, "project",
&err);
+ projectKernel = clCreateKernel(program, "project", &err);
if(err) printf("#%s, clCreateKernel: %s;\n", __func__,
clError(err));
- int headCount; // :-)
if((err = clEnqueueReadBuffer(getCommandQueue(), leftColumn,
CL_TRUE, 0, sizeof(int), &headCount , 0, NULL, NULL)))
printf("#%s, clEnqueueReadBuffer (left): %s;\n",
__func__, clError(err));
- clTail newTailDefinition = {.count = headCount}; // :-)
+ newTailDefinition = (clTail){.count = headCount}; // :-)
if((err = clEnqueueReadBuffer(getCommandQueue(), rightColumn,
CL_TRUE, sizeof(int), sizeof(int), &newTailDefinition.base , 0, NULL, NULL)))
printf("#%s, clEnqueueReadBuffer (right): %s;\n",
__func__, clError(err));
- BAT* result = BATnew(TYPE_void, ATOMtype(right->ttype), 0);
+ result = BATnew(TYPE_void, ATOMtype(right->ttype), 0);
{
const unsigned int newIndex =
getNextFreeDecomposedBATSlotIndex();
DecomposedBATSlot* slot =
getDecomposedBATSlotForIndex(newIndex);
@@ -168,7 +178,6 @@ str BWDLeftJoinApproximate(bat * res, ba
if(err) printf("#%s, clCreateBuffer: %s;\n", __func__,
clError(err));
}
- int i;
for (i = 0; i < 3; ++i) {
if((err = clSetKernelArg(projectKernel, i,
sizeof(cl_mem), &((cl_mem[]){
batTailApproximation(result), leftColumn, rightColumn}[i]
@@ -215,71 +224,79 @@ str BWDLeftJoinRefine(bat * res, bat * l
if (!approx || !*approx) {
printf("bwd.%s : no approximation provided, falling back to
normal leftjoin\n", __func__);
return ALGleftjoin(res, l, r);
+ } else {
+ BAT* left = BATdescriptor(*l);
+ BAT* right = BATdescriptor(*r);
+ BAT* refinement;
+ BAT* approximation = BATdescriptor(*approx);
+ const size_t approximationBits =
batTailApproximationBits(right);
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list