def per_machine_target_cores(cores, num_jobs):
    """Select target cores on larger machines to leave room for batch script and controller.

    On resource constrained environments, we want to pack all bcbio submissions onto a specific
    number of machines. This gives up some cores to enable sharing cores with the controller
    and batch script on larger machines.
    """
    if cores >= 32 and num_jobs == 1:
        cores = cores - 2
    elif cores >= 16 and num_jobs in [1, 2]:
        cores = cores - 1
    return cores