Ejemplo n.º 1
0
    def __init__(self, devicetype="GPU",):
        """
        Constructor of the class
        """

        self.verbose = True
        self.frames_folder = ""
        self.corrected_folder = ""
        self.aligned_folder = ""
        self.darkprefix = '' #'CdCO3_1_3f_dark_'
        self.dataprefix = '' #'CdCO3_1_3f_data_'
        self.flatprefix = '' #'CdCO3_1_3f_ref_'
        self.suffix = ".edf"

        self.setup()
        self.devicetype = devicetype
        kernel_path = "openCL/correction.cl"
        kernel_src = open(kernel_path).read()
        self.ctx = ocl.create_context(devicetype=devicetype)
#        self.device
#        self.ctx = pyopencl.Context(devices=[pyopencl.get_platforms()[self.device[0]].get_devices()[self.device[1]]])
#        print self.ctx.devices[0]
        self.queue = pyopencl.CommandQueue(self.ctx)
        self.program = pyopencl.Program(self.ctx, kernel_src).build() #.build('-D WORKGROUP_SIZE=%s' % wg_size)
        self.wg = (1, 1)
        self.dark_data = None
        self.dark_ref = None
Ejemplo n.º 2
0
    def __init__(
        self,
        devicetype="GPU",
    ):
        """
        Constructor of the class
        """

        #TODO: the following are user-defined
        self.verbose = True
        self.frames_folder = "/mnt/data/ID21-FullFieldXanes/CdCO3_1_3f"
        self.corrected_folder = "testframes"
        self.aligned_folder = "aligned"
        self.darkprefix = 'CdCO3_1_3f_dark_'
        self.dataprefix = 'CdCO3_1_3f_data_'
        self.flatprefix = 'CdCO3_1_3f_ref_'
        self.suffix = ".edf"

        self.devicetype = devicetype
        kernel_path = "openCL/correction.cl"
        kernel_src = open(kernel_path).read()
        self.ctx = ocl.create_context(devicetype=devicetype)
        #        self.device
        #        self.ctx = pyopencl.Context(devices=[pyopencl.get_platforms()[self.device[0]].get_devices()[self.device[1]]])
        #        print self.ctx.devices[0]
        self.queue = pyopencl.CommandQueue(self.ctx)
        self.program = pyopencl.Program(
            self.ctx,
            kernel_src).build()  #.build('-D WORKGROUP_SIZE=%s' % wg_size)
        self.wg = (1, 1)
        self.dark_data = None
        self.dark_ref = None
Ejemplo n.º 3
0
        if opts in ["-d", "--debug"]:
            level = logging.DEBUG
#            sys.argv.pop(sys.argv.index(opts))
        elif opts in ["-i", "--info"]:
            level = logging.INFO
#            sys.argv.pop(sys.argv.index(opts))
        elif opts in ["-f", "--force"]:
            force_build = True
        elif opts in ["-r", "--really-force"]:
            force_remove = True
            force_build = True

    mylogger = logging.getLogger(basename)
    mylogger.setLevel(level)
    mylogger.debug("tests loaded from file: %s" % basename)
    if force_build:
        UtilsTest.forceBuild(force_remove)
    else:
        UtilsTest.deep_reload()
    return mylogger


################################################################################
# This is very specific to PyOpenCL
################################################################################

import sift
from sift.opencl import ocl
ctx = ocl.create_context("GPU")
logger.info("working on %s" % ctx.devices[0].name)
Ejemplo n.º 4
0
    if options.force:
        force_build = True
    if options.remove:
        force_remove = True
        force_build = True
    mylogger = logging.getLogger(basename)
    mylogger.setLevel(level)
    mylogger.debug("tests loaded from file: %s" % basename)
    if force_build:
        UtilsTest.forceBuild(force_remove)
    else:
        UtilsTest.deep_reload()
    return mylogger
################################################################################
# This is very specific to PyOpenCL
################################################################################

import sift
from sift.opencl import ocl
#This is the shared context for all tests:
if "," in options.device: #Form 0,1
    platform, device = options.device.split(",", 1)
    platform = int(platform[-1])
    device = int(device[0])
    ctx = ocl.create_context(platformid=platform, deviceid=device)
else:
    ctx = ocl.create_context(devicetype=options.device)
print("working on %s" % ctx.devices[0].name)


Ejemplo n.º 5
0
    dirname, basename = os.path.split(os.path.abspath(filename))
    basename = os.path.splitext(basename)[0]
    force_build = False
    level = logging.WARN
    for opts in sys.argv[1:]:
        if opts in ["-d", "--debug"]:
            level = logging.DEBUG
#            sys.argv.pop(sys.argv.index(opts))
        elif opts in ["-i", "--info"]:
            level = logging.INFO
#            sys.argv.pop(sys.argv.index(opts))
        elif opts in ["-f", "--force"]:
            force_build = True
#            sys.argv.pop(sys.argv.index(opts))
    logger = logging.getLogger(basename)
    logger.setLevel(level)
    logger.debug("tests loaded from file: %s" % basename)
    if force_build:
        UtilsTest.forceBuild()
    return logger

################################################################################
# This is very specific to PyOpenCL
################################################################################

import sift
from sift.opencl import ocl
ctx = ocl.create_context("GPU")
logger.info("working on %s" % ctx.devices[0].name)