Beispiel #1
0
def pytest_addoption(parser):
    api_ids = supported_api_ids()

    parser.addoption(
        "--api",
        action="store",
        help=
        "Backend API. If 'supported' is chosen, will run on all available ones.",
        default="supported",
        choices=api_ids + ["supported"])
    parser.addoption("--device-include-mask",
                     action="append",
                     help="Run tests on matching devices only",
                     default=[])
    parser.addoption(
        "--include-duplicate-devices",
        action="store_true",
        help=
        "Run tests on all available devices and not only on uniquely named ones.",
        default=False)
    parser.addoption(
        "--heavy-performance-load",
        action="store_true",
        help=
        ("Use large data sizes and numbers of iterations for performance tests. "
         "Recommended for high-tier videocards."),
        default=False)
    parser.addoption("--transform",
                     action="store",
                     help=("The type of polynomial transform to use for tests "
                           "that can use different transform types."),
                     default="all",
                     choices=["NTT", "FFT", "all"])
Beispiel #2
0
def get_apis(config):
    """
    Get list of APIs to test, based on command line options and their availability.
    """
    # if we import it in the header, it messes up with coverage results
    import reikna.cluda as cluda

    conf_api_id = config.option.api

    if conf_api_id == "supported":
        api_ids = cluda.supported_api_ids()
    else:
        if not cluda.supports_api(conf_api_id):
            raise Exception("Requested API " + conf_api_id + " is not supported.")
        api_ids = [conf_api_id]
    apis = [cluda.get_api(api_id) for api_id in api_ids]
    return apis, api_ids
Beispiel #3
0
def get_apis(config):
    """
    Get list of APIs to test, based on command line options and their availability.
    """
    # if we import it in the header, it messes up with coverage results
    import reikna.cluda as cluda

    conf_api_id = config.option.api

    if conf_api_id == "supported":
        api_ids = cluda.supported_api_ids()
    else:
        if not cluda.supports_api(conf_api_id):
            raise Exception("Requested API " + conf_api_id +
                            " is not supported.")
        api_ids = [conf_api_id]
    apis = [cluda.get_api(api_id) for api_id in api_ids]
    return apis, api_ids
Beispiel #4
0
def pytest_generate_tests(metafunc):

    config = metafunc.config

    if 'thread' in metafunc.fixturenames:

        api_opt = config.option.api
        api_ids = supported_api_ids() if api_opt == 'supported' else [api_opt]

        vals = []
        ids = []
        for api_id in api_ids:
            api = get_api(api_id)
            devices = find_devices(
                api,
                include_devices=config.option.device_include_mask,
                include_duplicate_devices=config.option.
                include_duplicate_devices)
            for pnum in sorted(devices.keys()):
                dnums = sorted(devices[pnum])
                for dnum in dnums:
                    vals.append((api_id, pnum, dnum))
                    ids.append("{api_id}:{pnum}:{dnum}".format(api_id=api_id,
                                                               pnum=pnum,
                                                               dnum=dnum))

        if len(vals) == 0:
            raise RuntimeError(
                "Neither PyCUDA nor PyOpenCL could find any suitable devices. "
                "Check your system configuration.")

        metafunc.parametrize("thread", vals, ids=ids, indirect=True)

    if 'transform_type' in metafunc.fixturenames:

        if config.option.transform == 'all':
            vals = ['NTT', 'FFT']
        else:
            vals = [config.option.transform]

        metafunc.parametrize("transform_type", vals)
Beispiel #5
0
def pytest_generate_tests(metafunc):

    config = metafunc.config

    if 'thread' in metafunc.fixturenames:

        api_opt = config.option.api
        api_ids = supported_api_ids() if api_opt == 'supported' else [api_opt]

        vals = []
        ids = []
        for api_id in api_ids:
            api = get_api(api_id)
            devices = find_devices(
                api,
                include_devices=config.option.device_include_mask,
                include_duplicate_devices=config.option.
                include_duplicate_devices)
            for pnum in sorted(devices.keys()):
                dnums = sorted(devices[pnum])
                for dnum in dnums:
                    vals.append((api_id, pnum, dnum))
                    ids.append("{api_id}:{pnum}:{dnum}".format(api_id=api_id,
                                                               pnum=pnum,
                                                               dnum=dnum))

        metafunc.parametrize("thread", vals, ids=ids, indirect=True)

    if 'transform_type' in metafunc.fixturenames:

        if config.option.transform == 'all':
            vals = ['NTT', 'FFT']
        else:
            vals = [config.option.transform]

        metafunc.parametrize("transform_type", vals)