Пример #1
0
def test_context_limits():
    log.info("test_context_limits()")
    #figure out how many contexts we can have on each card:
    cuda_devices = init_all_devices()
    ec = getattr(encoder_module, "Encoder")
    MAX_ENCODER_CONTEXTS_PER_DEVICE = 64
    log("")
    for encoding in encoder_module.get_encodings():
        for w,h in TEST_DIMENSIONS:
            log("test_context_limits() %s @ %sx%s" % (encoding, w, h))
            src_format = encoder_module.get_input_colorspaces()[0]
            dst_formats = encoder_module.get_output_colorspaces(encoding, src_format)
            for device_id in cuda_devices:
                device_info = get_device_info(device_id)
                options = {"cuda_device" : device_id}
                encoders = []
                for i in range(MAX_ENCODER_CONTEXTS_PER_DEVICE):
                    e = ec()
                    encoders.append(e)
                    try:
                        e.init_context(w, h, src_format, dst_formats, encoding, 20, 0, None, options)
                    except Exception as e:
                        log.warn("failed to create context %s on %s: %s", i, device_info, e)
                        break
                log.info("device %s managed %s contexts at %sx%s", device_info, len(encoders)-1, w, h)
                for encoder in encoders:
                    try:
                        encoder.clean()
                    except Exception as e:
                        log("encoder cleanup error: %s" % e)
    log("")
Пример #2
0
def test_context_limits():
    log.info("test_context_limits()")
    #figure out how many contexts we can have on each card:
    cuda_devices = init_all_devices()
    ec = getattr(encoder_module, "Encoder")
    MAX_ENCODER_CONTEXTS_PER_DEVICE = 64
    log("")
    for encoding in encoder_module.get_encodings():
        for w, h in TEST_DIMENSIONS:
            log("test_context_limits() %s @ %sx%s" % (encoding, w, h))
            src_format = encoder_module.get_input_colorspaces(encoding)[0]
            dst_formats = encoder_module.get_output_colorspaces(
                encoding, src_format)
            for device_id in cuda_devices:
                device_info = get_device_info(device_id)
                options = {"cuda_device": device_id}
                encoders = []
                for i in range(MAX_ENCODER_CONTEXTS_PER_DEVICE):
                    e = ec()
                    encoders.append(e)
                    try:
                        e.init_context(w, h, src_format, dst_formats, encoding,
                                       20, 0, None, options)
                    except Exception as e:
                        log.warn("failed to create context %s on %s: %s", i,
                                 device_info, e)
                        break
                log.info("device %s managed %s contexts at %sx%s", device_info,
                         len(encoders) - 1, w, h)
                for encoder in encoders:
                    try:
                        encoder.clean()
                    except Exception as e:
                        log("encoder cleanup error: %s" % e)
    log("")
Пример #3
0
def test_parallel_encode():
    cuda_devices = init_all_devices()
    ec = getattr(encoder_module, "Encoder")
    encoding = encoder_module.get_encodings()[0]
    log("")
    log.info(
        "test_parallel_encode() will test one %s encoder using %s encoding on each of %s in parallel",
        ec, encoding, cuda_devices)
    w, h = 1280, 720
    IMAGE_COUNT = 40
    ENCODER_CONTEXTS_PER_DEVICE = 10
    src_format = encoder_module.get_input_colorspaces()[0]
    dst_formats = encoder_module.get_output_colorspaces(encoding, src_format)
    log("generating %s images..." % IMAGE_COUNT)
    images = []
    for _ in range(IMAGE_COUNT):
        images += gen_src_images(src_format, w, h, 1)
    log("%s images generated", IMAGE_COUNT)
    encoders = []
    for device_id in cuda_devices:
        device_info = get_device_info(device_id)
        options = {"cuda_device": device_id}
        for i in range(ENCODER_CONTEXTS_PER_DEVICE):
            e = ec()
            e.init_context(w, h, src_format, dst_formats, encoding, 0, 100,
                           None, options)
            log("encoder %s for device %s initialized", i, device_id)
            info = "%s / encoder %s" % (device_info, i)
            encoders.append((info, e, images))
    log("%s encoders initialized: %s", len(encoders), [e[1] for e in encoders])
    threads = []
    i = 0
    for info, encoder, images in encoders:
        name = "Context %s : %s" % (i, info)
        thread = threading.Thread(target=encoding_thread,
                                  name=name,
                                  args=(encoder, src_format, w, h, images,
                                        name))
        threads.append(thread)
        i += 1
    log("%s threads created: %s", len(threads), threads)
    log("starting all threads")
    log("")
    for thread in threads:
        thread.start()
    log("%s threads started - waiting for completion", len(threads))
    for thread in threads:
        thread.join()
    log("all threads ended")
    for _, encoder, _ in encoders:
        encoder.clean()
    log("")
Пример #4
0
def test_parallel_encode():
    cuda_devices = init_all_devices()
    ec = getattr(encoder_module, "Encoder")
    encoding = encoder_module.get_encodings()[0]
    log("")
    log.info("test_parallel_encode() will test one %s encoder using %s encoding on each of %s in parallel", ec, encoding, cuda_devices)
    w, h = 1280, 720
    IMAGE_COUNT = 40
    ENCODER_CONTEXTS_PER_DEVICE = 10
    src_format = encoder_module.get_input_colorspaces()[0]
    dst_formats = encoder_module.get_output_colorspaces(encoding, src_format)
    log("generating %s images..." % IMAGE_COUNT)
    images = []
    for _ in range(IMAGE_COUNT):
        images += gen_src_images(src_format, w, h, 1)
    log("%s images generated", IMAGE_COUNT)
    encoders = []
    for device_id in cuda_devices:
        device_info = get_device_info(device_id)
        options = {"cuda_device" : device_id}
        for i in range(ENCODER_CONTEXTS_PER_DEVICE):
            e = ec()
            e.init_context(w, h, src_format, dst_formats, encoding, 0, 100, None, options)
            log("encoder %s for device %s initialized", i, device_id)
            info = "%s / encoder %s" % (device_info, i)
            encoders.append((info, e, images))
    log("%s encoders initialized: %s", len(encoders), [e[1] for e in encoders])
    threads = []
    i = 0
    for info, encoder, images in encoders:
        name = "Context %s : %s" % (i, info)
        thread = threading.Thread(target=encoding_thread, name=name, args=(encoder, src_format, w, h, images, name))
        threads.append(thread)
        i += 1
    log("%s threads created: %s", len(threads), threads)
    log("starting all threads")
    log("")
    for thread in threads:
        thread.start()
    log("%s threads started - waiting for completion", len(threads))
    for thread in threads:
        thread.join()
    log("all threads ended")
    for _, encoder, _ in encoders:
        encoder.clean()
    log("")