def _tune_sfm(n, stride, func_regs):
    """
    Outputs the 'opimal' block and grid configuration
    for the sample discrete kernel.
    """
    from gpustats.util import info

    #info = DeviceInfo()
    comp_cap = info.compute_cap
    max_smem = info.shared_mem * 0.8
    max_threads = int(info.max_block_threads * 0.5)
    max_regs = 0.9 * info.max_registers

    # We want smallest dim possible in x dimsension while
    # still reading mem correctly

    if comp_cap[0] == 1:
        xdim = 16
    else:
        xdim = 32


    def sfm_config_ok(xdim, ydim, stride, func_regs, max_regs, max_smem, max_threads):
        ok = 4*(xdim*stride + 1*xdim) < max_smem and func_regs*ydim*xdim < max_regs
        return ok and xdim*ydim <= max_threads

    ydim = 2
    while sfm_config_ok(xdim, ydim, stride, func_regs, max_regs, max_smem, max_threads):
        ydim += 1

    ydim -= 1

    nblocks = int(xdim/n) + 1

    return (nblocks,1), (xdim,ydim,1)
dataset/ETHPy150Open dukestats/gpustats/gpustats/sampler.py/_tune_sfm/swapped operands of `/`