Example #1
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("")
Example #2
0
def test_parallel_encode():
    cuda_devices = encoder_module.get_cuda_devices()
    ec = getattr(encoder_module, "Encoder")
    encoding = encoder_module.get_encodings()[0]
    log("")
    log("test_parallel_encode() will test one %s encoder using %s encoding on each of %s in parallel"
        % (ec, encoding, cuda_devices))
    w, h = 1920, 1080
    IMAGE_COUNT = 20
    ENCODER_CONTEXTS_PER_DEVICE = 4
    src_format = encoder_module.get_colorspaces()[0]
    log("generating %s images..." % IMAGE_COUNT)
    images = []
    for _ in range(IMAGE_COUNT):
        images += gen_src_images(src_format, w, h, 1)
        sys.stdout.write(".")
        sys.stdout.flush()
    log("%s images generated" % IMAGE_COUNT)
    encoders = []
    for device_id, device_info in cuda_devices.items():
        options = {"cuda_device": device_id}
        for i in range(ENCODER_CONTEXTS_PER_DEVICE):
            e = ec()
            e.init_context(w, h, src_format, encoding, 20, 0, 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 = "Card %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("")
Example #3
0
def test_parallel_encode():
    from xpra.codecs.nvenc import encoder as encoder_module   #@UnresolvedImport
    cuda_devices = encoder_module.get_cuda_devices()
    ec = getattr(encoder_module, "Encoder")
    encoding = encoder_module.get_encodings()[0]
    print("")
    print("test_parallel_encode() will test one %s encoder using %s encoding on each of %s in parallel" % (ec, encoding, cuda_devices))
    w, h = 1920, 1080
    IMAGE_COUNT = 20
    ENCODER_CONTEXTS_PER_DEVICE = 4
    src_format = encoder_module.get_colorspaces()[0]
    print("generating %s images..." % IMAGE_COUNT)
    images = []
    for _ in range(IMAGE_COUNT):
        images += gen_src_images(src_format, w, h, 1)
        sys.stdout.write(".")
        sys.stdout.flush()
    print("%s images generated" % IMAGE_COUNT)
    encoders = []
    for device_id, device_info in cuda_devices.items():
        options = {"cuda_device" : device_id}
        for i in range(ENCODER_CONTEXTS_PER_DEVICE):
            e = ec()
            e.init_context(w, h, src_format, encoding, 20, 0, options)
            print("encoder %s for device %s initialized" % (i, device_id))
            info = "%s / encoder %s" % (device_info, i)
            encoders.append((info, e, images))
    print("%s encoders initialized: %s" % (len(encoders), [e[1] for e in encoders]))
    threads = []
    i = 0
    for info, encoder, images in encoders:
        name = "Card %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
    print("%s threads created: %s" % (len(threads), threads))
    print("starting all threads")
    print("")
    for thread in threads:
        thread.start()
    print("%s threads started - waiting for completion" % len(threads))
    for thread in threads:
        thread.join()
    print("all threads ended")
    for _, encoder, _ in encoders:
        encoder.clean()
    print("")
Example #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("")