コード例 #1
0
	def loadCL(self, filepath):
		print("Loading OpenCL Kernel")
		self.kernel_file = open(filepath, "r")
		buildDir = self.getDir(filepath)

		self.build_options = ""
		self.build_options = self.build_options + "-I "+buildDir
		self.build_options = self.build_options + " -D VGL_SHAPE_NCHANNELS={0}".format(vc.VGL_SHAPE_NCHANNELS())
		self.build_options = self.build_options + " -D VGL_SHAPE_WIDTH={0}".format(vc.VGL_SHAPE_WIDTH())
		self.build_options = self.build_options + " -D VGL_SHAPE_HEIGHT={0}".format(vc.VGL_SHAPE_HEIGHT())
		self.build_options = self.build_options + " -D VGL_SHAPE_LENGTH={0}".format(vc.VGL_SHAPE_LENGTH())
		self.build_options = self.build_options + " -D VGL_MAX_DIM={0}".format(vc.VGL_MAX_DIM())
		self.build_options = self.build_options + " -D VGL_ARR_SHAPE_SIZE={0}".format(vc.VGL_ARR_SHAPE_SIZE())
		self.build_options = self.build_options + " -D VGL_ARR_CLSTREL_SIZE={0}".format(vc.VGL_ARR_CLSTREL_SIZE())
		self.build_options = self.build_options + " -D VGL_STREL_CUBE={0}".format(vc.VGL_STREL_CUBE())
		self.build_options = self.build_options + " -D VGL_STREL_CROSS={0}".format(vc.VGL_STREL_CROSS())
		self.build_options = self.build_options + " -D VGL_STREL_GAUSS={0}".format(vc.VGL_STREL_GAUSS())
		self.build_options = self.build_options + " -D VGL_STREL_MEAN={0}".format(vc.VGL_STREL_MEAN())

		#print("Build Options:\n", self.build_options)

		# READING THE HEADER FILES BEFORE COMPILING THE KERNEL
		for file in glob.glob(buildDir+"/*.h"):
			self.pgr = cl.Program(self.ctx, open(file, "r"))

		if ((self.builded == False)):
			self.pgr = cl.Program(self.ctx, self.kernel_file.read())
			self.pgr.build(options=self.build_options)
			#self.pgr.build()
			self.builded = True
		else:
			print("Kernel already builded. Going to next step...")

		self.kernel_file.close()
コード例 #2
0
ファイル: vglShape.py プロジェクト: arturxz/TCC
    def vglCreateShape(self, shape, ndim, bps=8):

        self.ndim = ndim
        self.bps = bps
        self.size = 1

        if ((bps == 1) and (shape[0] != 1)):
            print(
                "Error: Image with 1 bps and mode then one color channels(!)")
            return 1

        maxi = ndim
        c = shape[vc.VGL_SHAPE_NCHANNELS()]
        w = shape[vc.VGL_SHAPE_WIDTH()]

        if (ndim == 1):
            maxi == 2

        for i in range(0, vc.VGL_MAX_DIM() + 1):
            if (i <= maxi):
                self.shape[i] = shape[i]

                if (i == 0):
                    self.offset[i] = 1
                elif (i == 2):
                    self.offset[i] = self.findWidthStep(bps, w, c)
                else:
                    self.offset[i] = shape[i - 1] * self.offset[i - 1]
            else:
                self.shape[i] = 1
                self.offset[i] = 0
        self.size *= self.shape[maxi] * self.offset[maxi]
コード例 #3
0
ファイル: vglShape.py プロジェクト: arturxz/TCC
    def asVglClShape(self):

        result = VglClShape()
        result.ndim = np.int32(self.ndim)
        result.size = np.int32(self.size)

        for i in range(0, vc.VGL_MAX_DIM() + 1):
            result.shape[i] = np.int32(self.shape[i])
            result.offset[i] = np.int32(self.offset[i])

        if (self.ndim == 1):
            result.shape[vc.VGL_SHAPE_WIDTH()] = np.int32(self.getWidth())
            result.offset[vc.VGL_SHAPE_WIDTH()] = np.int32(
                result.shape[vc.VGL_SHAPE_WIDTH() - 1] *
                result.offset[vc.VGL_SHAPE_WIDTH() - 1])
            result.shape[vc.VGL_SHAPE_HEIGHT()] = np.int32(self.getHeight())
            result.offset[vc.VGL_SHAPE_HEIGHT()] = np.int32(
                result.shape[vc.VGL_SHAPE_HEIGHT() - 1] *
                result.offset[vc.VGL_SHAPE_HEIGHT() - 1])

        return result
コード例 #4
0
ファイル: vglShape.py プロジェクト: arturxz/TCC
 def getWidthIn(self):
     return self.shape[vc.VGL_SHAPE_WIDTH()]
コード例 #5
0
ファイル: vglShape.py プロジェクト: arturxz/TCC
 def getWidth(self):
     if (self.ndim == 1):
         return self.shape[vc.VGL_SHAPE_WIDTH()] * self.shape[
             vc.VGL_SHAPE_HEIGHT()]
     return self.shape[vc.VGL_SHAPE_WIDTH()]