Пример #1
0
def test_command_prefix_tcmalloc_int8(precision, mock_glob):
    """ For Int8 models, TCMalloc should be enabled by default and models should include
     LD_PRELOAD in the command prefix, unless disable_tcmalloc=True is set """
    platform_util = MagicMock()
    args = MagicMock(verbose=True, model_name=test_model_name)
    test_tcmalloc_lib = "/usr/lib/libtcmalloc.so.4.2.6"
    mock_glob.return_value = [test_tcmalloc_lib]
    os.environ["PYTHON_EXE"] = "python"
    os.environ["MPI_NUM_PROCESSES"] = "None"
    args.socket_id = 0
    args.precision = precision

    # If tcmalloc is not disabled, we should have LD_PRELOAD in the prefix
    args.disable_tcmalloc = False
    base_model_init = BaseModelInitializer(args, [], platform_util)
    command_prefix = base_model_init.get_command_prefix(args.socket_id)
    assert "LD_PRELOAD={}".format(test_tcmalloc_lib) in command_prefix
    assert "numactl --cpunodebind=0 --membind=0" in command_prefix

    # If tcmalloc is disabled, LD_PRELOAD shouild not be in the prefix
    args.disable_tcmalloc = True
    base_model_init = BaseModelInitializer(args, [], platform_util)
    command_prefix = base_model_init.get_command_prefix(args.socket_id)
    assert "LD_PRELOAD={}".format(test_tcmalloc_lib) not in command_prefix
    assert "numactl --cpunodebind=0 --membind=0" in command_prefix

    # If numactl is set to false, we should not have numactl in the prefix
    args.disable_tcmalloc = False
    base_model_init = BaseModelInitializer(args, [], platform_util)
    command_prefix = base_model_init.get_command_prefix(args.socket_id,
                                                        numactl=False)
    assert "LD_PRELOAD={}".format(test_tcmalloc_lib) in command_prefix
    assert "numactl" not in command_prefix
def test_command_prefix_tcmalloc_fp32(precision, mock_glob):
    """ FP32 models should have TC Malloc disabled by default, but models should
    include LD_PRELOAD in the command prefix if disable_tcmalloc=False is explicitly set. """
    platform_util = MagicMock()
    args = MagicMock(verbose=True, model_name=test_model_name)
    test_tcmalloc_lib = "/usr/lib/libtcmalloc.so.4.2.6"
    mock_glob.return_value = [test_tcmalloc_lib]
    os.environ["PYTHON_EXE"] = "python"
    args.socket_id = 0
    args.precision = precision

    # By default, TCMalloc should not be used
    base_model_init = BaseModelInitializer(args, [], platform_util)
    command_prefix = base_model_init.get_command_prefix(args.socket_id)
    assert "LD_PRELOAD={}".format(test_tcmalloc_lib) not in command_prefix
    assert "numactl --cpunodebind=0 --membind=0" in command_prefix

    # If tcmalloc is disabled, LD_PRELOAD shouild not be in the prefix
    args.disable_tcmalloc = False
    base_model_init = BaseModelInitializer(args, [], platform_util)
    command_prefix = base_model_init.get_command_prefix(args.socket_id)
    assert "LD_PRELOAD={}".format(test_tcmalloc_lib) in command_prefix
    assert "numactl --cpunodebind=0 --membind=0" in command_prefix

    # If numactl is set to false, we should not have numactl in the prefix
    args.disable_tcmalloc = True
    base_model_init = BaseModelInitializer(args, [], platform_util)
    command_prefix = base_model_init.get_command_prefix(args.socket_id,
                                                        numactl=False)
    assert "LD_PRELOAD={}".format(test_tcmalloc_lib) not in command_prefix
    assert "numactl" not in command_prefix
Пример #3
0
def test_command_prefix_numa_multi_instance(precision, mock_glob):
    """ Tests that models don't get a numactl command prefix from
    base_model_init.get_command_prefix, if numa_cores_per_instance is set, since numactl
    commands will be added later for each instance run. """
    platform_util = MagicMock()
    args = MagicMock(verbose=True, model_name=test_model_name)
    test_tcmalloc_lib = "/usr/lib/libtcmalloc.so.4.2.6"
    mock_glob.return_value = [test_tcmalloc_lib]
    os.environ["PYTHON_EXE"] = "python"
    args.socket_id = 0
    args.precision = precision
    args.numa_cores_per_instance = 4

    base_model_init = BaseModelInitializer(args, [], platform_util)
    command_prefix = base_model_init.get_command_prefix(args.socket_id)
    assert "numactl" not in command_prefix