Esempio n. 1
0
 def openMirrorKernel(self, suffix):
     kernel = copy.deepcopy(self.currentKernel)
     kernel.kernelName = self.currentKernel.kernelName + suffix
     self.kernels.append(kernel)
     self.mirrorKernel = kernel
     self.kernelCalls.append(KernelCall.generated(kernel))
     return kernel
Esempio n. 2
0
 def createAgg(name, minEntries, payload, codegen):
     mem = HashTableMemory(minEntries, codegen)
     mem.ht = mem.addColumn(qlib.Type.AGG_HT + "<" + payload.typeName + ">",
                            name)
     call = KernelCall.library(qlib.Krnl.INIT_AGG_HT,
                               [mem.ht.getGPU(), mem.numEntries],
                               payload.typeName)
     codegen.gpumem.cudaMallocHT.add(call.get())
     mem.addToKernel(codegen.currentKernel)
     return mem
Esempio n. 3
0
    def createMulti(name, minHtEntries, payload, numPayloads, codegen):
        mem = HashTableMemory(minHtEntries, codegen)
        mem.ht = mem.addColumn(qlib.Type.MULTI_HT, name)
        mem.payload = mem.addSizedColumn(payload.typeName, name + "_payload",
                                         numPayloads)
        call = KernelCall.library(qlib.Krnl.INIT_MULTI_HT,
                                  [mem.ht.getGPU(), mem.numEntries])
        codegen.gpumem.cudaMallocHT.add(call.get())

        mem.addToKernel(codegen.currentKernel)
        return mem
Esempio n. 4
0
    def htInsertMultiMatch(self, ctxt):

        # execute only when current thread has active elements
        with IfClause(ctxt.vars.activeVar, ctxt.codegen):

            # compute a (possibly) non-unique hash over all join attributes
            hashVar = Variable.val(CType.UINT64,
                                   "hash" + str(self.algExpr.opId),
                                   ctxt.codegen, intConst(0))
            with IfClause(ctxt.vars.activeVar, ctxt.codegen):
                Hash.attributes(self.algExpr.buildKeyAttributes, hashVar, ctxt)

            htRangeOffset = Variable.val(CType.INT,
                                         "offs" + str(self.algExpr.opId))
            ctxt.codegen.gpumem.local(htRangeOffset, intConst(0))

            scanCall = KernelCall.library("scanMultiHT", [
                self.htmem.ht.getGPU(), self.htmem.numEntries,
                htRangeOffset.getGPU()
            ])
            ctxt.codegen.kernelCalls.append(scanCall)

            ctxt.codegen.openMirrorKernel("_ins")

            emit(
                call(qlib.Fct.HASH_COUNT_MULTI,
                     [self.htmem.ht, self.htmem.numEntries, hashVar]),
                ctxt.codegen.currentKernel)

            ctxt.codegen.mirrorKernel.addVar(htRangeOffset)

            payl = self.payload.materialize("payl", ctxt.codegen.mirrorKernel,
                                            ctxt)

            emit(
                call(qlib.Fct.HASH_INSERT_MULTI, [
                    self.htmem.ht, self.htmem.payload, htRangeOffset,
                    self.htmem.numEntries, hashVar,
                    addressof(payl)
                ]), ctxt.codegen.mirrorKernel)
Esempio n. 5
0
 def openKernel(self, kernel):
     self.kernels.append(kernel)
     self.currentKernel = kernel
     self.kernelCalls.append(KernelCall.generated(kernel))
     return kernel
Esempio n. 6
0
File: gpuio.py Progetto: ngaut/dogqc
 def initVar(self, var, init):
     call = KernelCall.library(
         "initArray",
         [var.getGPU(), str(init), var.numElements], var.dataType)
     self.cudaMallocHT.add(call.get())