Changeset: 16f71dba1b05 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=16f71dba1b05
Modified Files:
        monetdb5/extras/bwd/91_bwd.sql
        monetdb5/extras/bwd/bwd.c
        monetdb5/extras/bwd/bwd.h
        monetdb5/extras/bwd/opt_bwd.mal
Branch: bwd
Log Message:

* implemented bwdreset to remove all (persistent) memory objects from the gpu


Unterschiede (104 Zeilen):

diff --git a/monetdb5/extras/bwd/91_bwd.sql b/monetdb5/extras/bwd/91_bwd.sql
--- a/monetdb5/extras/bwd/91_bwd.sql
+++ b/monetdb5/extras/bwd/91_bwd.sql
@@ -28,5 +28,8 @@ returns varchar(4096) external name bwd.
 create function bwdevices()
 returns table(platform int, device int, deviceDescription string, 
platformDescription string) external name bwd.deviceInfo;
 
+create function bwdreset()
+returns table(result string) external name bwd.bwdreset;
+
 create function bwdmemobjects()
 returns table(registryID int, batID int, approximationBits int, offsetBits 
int, isPersistent int, tailPositionsRefcount int, 
tailPositionsMemoryConsumption bigint, tailValuesRefcount int, 
tailValuesMemoryConsumption bigint) external name bwd.memObjectInfo;
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
@@ -251,10 +251,10 @@ void releaseMemObject(cl_mem object, cha
                printf ("error when relasing memobject %p: %s\n", object, 
clError(err));
 }
 
-void releaseCLMemObject(bat* subjectID){
+static inline void releasePotentiallyPersistentCLMemObject(bat* subjectID, int 
evenPersistent){
        BAT*    subject = BBPquickdesc(*subjectID,0);
        DecomposedBATSlot* slot = getDecomposedBATSlot(subject);
-       if(slot && !slot->isPersistentBAT){
+       if(slot && (!slot->isPersistentBAT || evenPersistent)){
                if(0) printf ("releasing bat %d\n", *subjectID);
                if(slot->tailApproximation){
                        releaseMemObject(slot->tailApproximation, 
"batTailApproximation", *subjectID);
@@ -272,10 +272,13 @@ void releaseCLMemObject(bat* subjectID){
                        /* getDecomposedBATSlot(subject)->used = 0; */
                        bzero(slot, sizeof(DecomposedBATSlot));
                }
-               
-               
-               
        }
+       BATunsetprop(subject, batRegistryIndex);
+
+}
+
+void releaseCLMemObject(bat* subjectID){
+       releasePotentiallyPersistentCLMemObject(subjectID, 0)   ;
 }
 
 str bwdinit(void){
@@ -283,6 +286,24 @@ str bwdinit(void){
        return MAL_SUCCEED;
 }
 
+str bwdreset(bat* resultBID){
+       int i;
+       BAT* result = BATnew(TYPE_void, TYPE_str, MAX_DECOMPOSED_BATS);
+       BATseqbase(result, 0);
+
+       for (i = 0; i<MAX_DECOMPOSED_BATS; ++i){
+               bat batID = getDecomposedBATSlotForIndex(i)->used;
+               if(batID){
+                       char resultValue[1024];
+                       releasePotentiallyPersistentCLMemObject((bat[]){batID}, 
1);
+                       snprintf(resultValue, 1024, "successfully liberated 
slot %d, bat %d", i, batID);
+                       BUNappend(result, resultValue, 0);
+               }
+       }
+       BBPkeepref((*resultBID = result->batCacheid));
+       return MAL_SUCCEED;
+}
+
 str memObjectInfo(bat* registryIDBID,
                                                                        bat*  
batIDBID,
                                                                        bat*  
approximationBitsBID,
diff --git a/monetdb5/extras/bwd/bwd.h b/monetdb5/extras/bwd/bwd.h
--- a/monetdb5/extras/bwd/bwd.h
+++ b/monetdb5/extras/bwd/bwd.h
@@ -8,7 +8,16 @@ extern str OPTBWD(Client cntxt, MalBlkPt
 str deviceInfo(bat * resPlatform, bat * resDevice, bat * resDesc, bat * 
resKernels);
 str bwd_result_column_wrap(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr 
pci);
 char* resolveBatToAttribute(bat bid, Client cntxt);
-
+str bwdreset(bat* resultBID);
+str memObjectInfo(bat* registryIDBID,
+                                                                       bat* 
batIDBID,
+                                                                       bat* 
approximationBitsBID,
+                                                                       bat* 
offsetBitsBID,
+                                                                       bat* 
isPersistentBID,
+                                                                       bat* 
tailPositionsRefcountBID,
+                                                                       bat* 
tailPositionsMemoryConsumptionBID,
+                                                                       bat* 
tailValuesRefcountBID,
+                                                                       bat* 
tailValuesMemoryConsumptionBID);
 str bwdinit();
 
 #endif /* _BWD_H_ */
diff --git a/monetdb5/extras/bwd/opt_bwd.mal b/monetdb5/extras/bwd/opt_bwd.mal
--- a/monetdb5/extras/bwd/opt_bwd.mal
+++ b/monetdb5/extras/bwd/opt_bwd.mal
@@ -256,6 +256,9 @@ comment "export a single value onto the 
 command deviceinfo()(platformID:bat[:oid,:int], 
deviceID:bat[:oid,:int],description:bat[:oid,:str], 
platformDescription:bat[:oid,:str])
 address deviceInfo;
 
+command bwdreset()(result:bat[:oid,:str])
+address bwdreset;
+
 command memobjectinfo()(bwdids:bat[:oid,:int], batids:bat[:oid,:int], 
approximationBits:bat[:oid,:int], offsetBits:bat[:oid,:int], 
isPersistent:bat[:oid,:int], tailPositionsReferences:bat[:oid,:int], 
tailPositionsMemoryConsumption:bat[:oid,:lng], 
tailValuesReferences:bat[:oid,:int], tailValuesMemoryConsumption:bat[:oid,:lng])
 address memObjectInfo;
 
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to