Пример #1
0
    def allocate(self):
        self.updateSettings()

        clock = utils.StopWatch()
        bufferNames = [b.name for b in self.settings.buffers]
        self.log("Allocating buffers <i> %s </i> ..." % bufferNames)
        width, height = utils.allocateBufferData(self.buffers)
        self.ip.SetDimensions(width, height)
        err = self.ip.Allocate()
        clock = utils.StopWatch()
        if err:
            self.logError(err)
            return False
        else:
            self.logSuccess("All buffers were allocated.", clock)
            self.needsAllocate = False

        clock = utils.StopWatch()
        for b in self.settings.buffers:
            if b.input:
                err = self.ip.WriteBufferToGPU(self.buffers[b.name])
                if err:
                    self.logError(err)
                    return False
        self.logSuccess("Data transfered to GPU.", clock)
        return True
Пример #2
0
    def allocate(self):
        self.updateSettings()

        clock = utils.StopWatch()
        bufferNames = [b.name for b in self.settings.buffers]
        self.log("Allocating buffers <i> %s </i> ..." % bufferNames)
        width, height = utils.allocateBufferData(self.buffers)
        self.ip.SetDimensions(width, height)
        err = self.ip.Allocate()
        clock = utils.StopWatch()
        if err:
            self.logError(err)
            return False
        else:
            self.logSuccess("All buffers were allocated.", clock)
            self.needsAllocate = False

        clock = utils.StopWatch()
        for b in self.settings.buffers:
            if b.input:
                err = self.ip.WriteBufferToGPU(self.buffers[b.name])
                if err:
                    self.logError(err)
                    return False
        self.logSuccess("Data transfered to GPU.", clock)
        return True
Пример #3
0
def runCommandLine(ipsettings, verbose):
    # Can't run non-gui version if there's no *.ip file
    if not ipsettings:
        err = "Must specify an existing *.ip file in the command-line version\n"
        err += "example: \n"
        err += "  gpuip --nogui smooth.ip"""
        terminate(err)

    def check_error(err):
        if err:
            terminate(err)

    def log(text, stopwatch = None, time = True):
        time = time and args.timestamp
        if verbose:
            stopwatchStr = str(stopwatch) if stopwatch else  ""
            timeStr = utils.getTimeStr() if time else ""
            print timeStr + text + " " + stopwatchStr

    overall_clock = utils.StopWatch()

    ### 0. Create gpuip items from settings
    ip, buffers, kernels = ipsettings.create()
    log("Created elements from settings.", overall_clock)

    ### 1. Build
    c = utils.StopWatch()
    check_error(ip.Build())
    log("Building kernels [%s]." %  [k.name for k in kernels], c)
    
    ### 2. Import data from images
    c = utils.StopWatch()
    for b in ipsettings.buffers:
        if b.input:
            log("Importing data from %s to %s" %(b.input, b.name))
            check_error(buffers[b.name].Read(b.input, utils.getNumCores()))
    log("Importing data done.", c)
            
    ### 3. Allocate and transfer data to GPU
    c = utils.StopWatch()
    width, height = utils.allocateBufferData(buffers)
    ip.SetDimensions(width, height)
    check_error(ip.Allocate())
    log("Allocating done.", c)
    c = utils.StopWatch()
    for b in ipsettings.buffers:
        if b.input:
            check_error(ip.WriteBufferToGPU(buffers[b.name]))
    log("Transfering data to GPU done.", c)

    ### 4. Process
    c = utils.StopWatch()
    check_error(ip.Run())
    log("Processing done.", c)

    ### 5. Export buffers to images
    c = utils.StopWatch()
    for b in ipsettings.buffers:
        if b.output:
            log("Exporting data from %s to %s" %(b.name, b.output))
            check_error(ip.ReadBufferFromGPU(buffers[b.name]))
            check_error(buffers[b.name].Write(b.output,utils.getNumCores()))
    log("Exporting data done.", c)

    log("\nAll steps done. Total runtime:", overall_clock, time = False)
Пример #4
0
def runCommandLine(ipsettings, verbose):
    # Can't run non-gui version if there's no *.ip file
    if not ipsettings:
        err = "Must specify an existing *.ip file in the command-line version\n"
        err += "example: \n"
        err += "  gpuip --nogui smooth.ip" ""
        terminate(err)

    def check_error(err):
        if err:
            terminate(err)

    def log(text, stopwatch=None, time=True):
        time = time and args.timestamp
        if verbose:
            stopwatchStr = str(stopwatch) if stopwatch else ""
            timeStr = utils.getTimeStr() if time else ""
            print timeStr + text + " " + stopwatchStr

    overall_clock = utils.StopWatch()

    ### 0. Create gpuip items from settings
    ip, buffers, kernels = ipsettings.create()
    log("Created elements from settings.", overall_clock)

    ### 1. Build
    c = utils.StopWatch()
    check_error(ip.Build())
    log("Building kernels [%s]." % [k.name for k in kernels], c)

    ### 2. Import data from images
    c = utils.StopWatch()
    for b in ipsettings.buffers:
        if b.input:
            log("Importing data from %s to %s" % (b.input, b.name))
            check_error(buffers[b.name].Read(b.input, utils.getNumCores()))
    log("Importing data done.", c)

    ### 3. Allocate and transfer data to GPU
    c = utils.StopWatch()
    width, height = utils.allocateBufferData(buffers)
    ip.SetDimensions(width, height)
    check_error(ip.Allocate())
    log("Allocating done.", c)
    c = utils.StopWatch()
    for b in ipsettings.buffers:
        if b.input:
            check_error(ip.WriteBufferToGPU(buffers[b.name]))
    log("Transfering data to GPU done.", c)

    ### 4. Process
    c = utils.StopWatch()
    check_error(ip.Run())
    log("Processing done.", c)

    ### 5. Export buffers to images
    c = utils.StopWatch()
    for b in ipsettings.buffers:
        if b.output:
            log("Exporting data from %s to %s" % (b.name, b.output))
            check_error(ip.ReadBufferFromGPU(buffers[b.name]))
            check_error(buffers[b.name].Write(b.output, utils.getNumCores()))
    log("Exporting data done.", c)

    log("\nAll steps done. Total runtime:", overall_clock, time=False)