Unverified Commit ce1481dd authored by Yuting Jiang's avatar Yuting Jiang Committed by GitHub
Browse files

Bug - Fix bug of detecting if gpu_index is none #275

**Description**
Fix bug of detecting if gpu_index is none.
parent 3d8721a2
...@@ -249,7 +249,7 @@ def __prepare_general_ib_command_params(self): ...@@ -249,7 +249,7 @@ def __prepare_general_ib_command_params(self):
msg_size = '-s ' + str(self._args.msg_size) msg_size = '-s ' + str(self._args.msg_size)
# Add GPUDirect for ib command # Add GPUDirect for ib command
gpu_enable = '' gpu_enable = ''
if self._args.gpu_index: if self._args.gpu_index is not None:
gpu = GPU() gpu = GPU()
if gpu.vendor == 'nvidia': if gpu.vendor == 'nvidia':
gpu_enable = ' --use_cuda={gpu_index}'.format(gpu_index=str(self._args.gpu_index)) gpu_enable = ' --use_cuda={gpu_index}'.format(gpu_index=str(self._args.gpu_index))
......
...@@ -117,8 +117,9 @@ def read_config(filename): ...@@ -117,8 +117,9 @@ def read_config(filename):
Path(test_config_file).unlink() Path(test_config_file).unlink()
@mock.patch('superbench.common.devices.GPU.vendor', new_callable=mock.PropertyMock)
@mock.patch('superbench.common.utils.network.get_ib_devices') @mock.patch('superbench.common.utils.network.get_ib_devices')
def test_ib_traffic_performance(self, mock_ib_devices): def test_ib_traffic_performance(self, mock_ib_devices, mock_gpu):
"""Test ib-traffic benchmark.""" """Test ib-traffic benchmark."""
# Test without ib devices # Test without ib devices
# Check registry. # Check registry.
...@@ -168,6 +169,22 @@ def test_ib_traffic_performance(self, mock_ib_devices): ...@@ -168,6 +169,22 @@ def test_ib_traffic_performance(self, mock_ib_devices):
command = benchmark._bin_name + benchmark._commands[0].split(benchmark._bin_name)[1] command = benchmark._bin_name + benchmark._commands[0].split(benchmark._bin_name)[1]
assert (command == expect_command) assert (command == expect_command)
parameters = '--ib_index 0 --iters 2000 --pattern one-to-one --hostfile hostfile --gpu_index 0'
mock_gpu.return_value = 'nvidia'
benchmark = benchmark_class(benchmark_name, parameters=parameters)
ret = benchmark._preprocess()
expect_command = 'ib_validation --hostfile hostfile --cmd_prefix "ib_write_bw -F ' + \
'--iters=2000 -d mlx5_0 -a --use_cuda=0" --input_config ' + os.getcwd() + '/config.txt'
command = benchmark._bin_name + benchmark._commands[0].split(benchmark._bin_name)[1]
assert (command == expect_command)
mock_gpu.return_value = 'amd'
benchmark = benchmark_class(benchmark_name, parameters=parameters)
ret = benchmark._preprocess()
expect_command = 'ib_validation --hostfile hostfile --cmd_prefix "ib_write_bw -F ' + \
'--iters=2000 -d mlx5_0 -a --use_rocm=0" --input_config ' + os.getcwd() + '/config.txt'
command = benchmark._bin_name + benchmark._commands[0].split(benchmark._bin_name)[1]
assert (command == expect_command)
# Custom config # Custom config
config = ['0,1', '1,0;0,1', '0,1;1,0', '1,0;0,1'] config = ['0,1', '1,0;0,1', '0,1;1,0', '1,0;0,1']
with open('test_config.txt', 'w') as f: with open('test_config.txt', 'w') as f:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment