Esempio n. 1
0
    def export_to_images(self):
        self.updateSettings()

        clock = utils.StopWatch()
        for b in self.settings.buffers:
            if b.output:
                self.log("Exporting data from buffer <i>%s</i> to <i>%s</i>." \
                         % (b.name, b.output))
                err = self.buffers[b.name].Write(b.output, utils.getNumCores())
                if err:
                    self.logError(err)
                    return False

        self.logSuccess("Buffer data transfered to images.", clock)
        return True
Esempio n. 2
0
    def export_to_images(self):
        self.updateSettings()

        clock = utils.StopWatch()
        for b in self.settings.buffers:
            if b.output:
                self.log("Exporting data from buffer <i>%s</i> to <i>%s</i>." \
                         % (b.name, b.output))
                err = self.buffers[b.name].Write(b.output, utils.getNumCores())
                if err:
                    self.logError(err)
                    return False

        self.logSuccess("Buffer data transfered to images.", clock)
        return True
Esempio n. 3
0
    def import_from_images(self):
        self.updateSettings()

        clock = utils.StopWatch()
        for b in self.settings.buffers:
            if b.input:
                self.log("Importing data from image <i>%s</i> to <i>%s</i>." \
                         % (b.input, b.name))
                err = self.buffers[b.name].Read(b.input, utils.getNumCores())
                if err:
                    self.logError(err)
                    return False
        self.logSuccess("Image data imported", clock)
        self.displayWidget.refreshDisplay()
        self.needsImport = False
        return True
Esempio n. 4
0
    def import_from_images(self):
        self.updateSettings()

        clock = utils.StopWatch()
        for b in self.settings.buffers:
            if b.input:
                self.log("Importing data from image <i>%s</i> to <i>%s</i>." \
                         % (b.input, b.name))
                err = self.buffers[b.name].Read(b.input, utils.getNumCores())
                if err:
                    self.logError(err)
                    return False
        self.logSuccess("Image data imported", clock)
        self.displayWidget.refreshDisplay()
        self.needsImport = False
        return True
Esempio n. 5
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)
Esempio n. 6
0
File: gpuip.py Progetto: k3rp/gpuip
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)