2828# HT disabled via CpuOptions
2929@pytest .mark .dimensions ("sa-east-1" , "c5.xlarge" , "alinux2" , "sge" )
3030@pytest .mark .dimensions ("sa-east-1" , "c5.xlarge" , "centos7" , "torque" )
31- def test_sit_disable_hyperthreading (region , scheduler , instance , os , pcluster_config_reader , clusters_factory ):
31+ def test_sit_disable_hyperthreading (
32+ region , scheduler , instance , os , pcluster_config_reader , clusters_factory , default_threads_per_core
33+ ):
3234 """Test Disable Hyperthreading for SIT clusters."""
3335 slots_per_instance = fetch_instance_slots (region , instance )
3436 cluster_config = pcluster_config_reader ()
3537 cluster = clusters_factory (cluster_config )
3638 remote_command_executor = RemoteCommandExecutor (cluster )
3739 scheduler_commands = get_scheduler_commands (scheduler , remote_command_executor )
38- _test_disable_hyperthreading_settings (remote_command_executor , scheduler_commands , slots_per_instance , scheduler )
40+ _test_disable_hyperthreading_settings (
41+ remote_command_executor ,
42+ scheduler_commands ,
43+ slots_per_instance ,
44+ scheduler ,
45+ default_threads_per_core = default_threads_per_core ,
46+ )
3947
4048 assert_no_errors_in_logs (remote_command_executor , scheduler )
4149
@@ -47,7 +55,9 @@ def test_sit_disable_hyperthreading(region, scheduler, instance, os, pcluster_co
4755@pytest .mark .dimensions ("us-west-2" , "m4.xlarge" , "centos8" , "slurm" )
4856# HT disabled via CpuOptions
4957@pytest .mark .dimensions ("us-west-1" , "c5.xlarge" , "ubuntu1804" , "slurm" )
50- def test_hit_disable_hyperthreading (region , scheduler , instance , os , pcluster_config_reader , clusters_factory ):
58+ def test_hit_disable_hyperthreading (
59+ region , scheduler , instance , os , pcluster_config_reader , clusters_factory , default_threads_per_core
60+ ):
5161 """Test Disable Hyperthreading for HIT clusters."""
5262 slots_per_instance = fetch_instance_slots (region , instance )
5363 cluster_config = pcluster_config_reader ()
@@ -61,6 +71,7 @@ def test_hit_disable_hyperthreading(region, scheduler, instance, os, pcluster_co
6171 scheduler ,
6272 hyperthreading_disabled = False ,
6373 partition = "ht-enabled" ,
74+ default_threads_per_core = default_threads_per_core ,
6475 )
6576 _test_disable_hyperthreading_settings (
6677 remote_command_executor ,
@@ -69,6 +80,7 @@ def test_hit_disable_hyperthreading(region, scheduler, instance, os, pcluster_co
6980 scheduler ,
7081 hyperthreading_disabled = True ,
7182 partition = "ht-disabled" ,
83+ default_threads_per_core = default_threads_per_core ,
7284 )
7385
7486 assert_no_errors_in_logs (remote_command_executor , scheduler )
@@ -81,17 +93,20 @@ def _test_disable_hyperthreading_settings(
8193 scheduler ,
8294 hyperthreading_disabled = True ,
8395 partition = None ,
96+ default_threads_per_core = 2 ,
8497):
85- expected_cpus_per_instance = slots_per_instance // 2 if hyperthreading_disabled else slots_per_instance
86- expected_threads_per_core = 1 if hyperthreading_disabled else 2
98+ expected_cpus_per_instance = (
99+ slots_per_instance // default_threads_per_core if hyperthreading_disabled else slots_per_instance
100+ )
101+ expected_threads_per_core = 1 if hyperthreading_disabled else default_threads_per_core
87102
88103 # Test disable hyperthreading on head node
89104 logging .info ("Test Disable Hyperthreading on head node" )
90105 result = remote_command_executor .run_remote_command ("lscpu" )
91106 if partition :
92107 # If partition is supplied, assume this is HIT setting where ht settings are at the queue level
93108 # In this case, ht is not disabled on head node
94- assert_that (result .stdout ).matches (r"Thread\(s\) per core:\s+{0}" .format (2 ))
109+ assert_that (result .stdout ).matches (r"Thread\(s\) per core:\s+{0}" .format (default_threads_per_core ))
95110 _assert_active_cpus (result .stdout , slots_per_instance )
96111 else :
97112 assert_that (result .stdout ).matches (r"Thread\(s\) per core:\s+{0}" .format (expected_threads_per_core ))
@@ -128,10 +143,12 @@ def _test_disable_hyperthreading_settings(
128143 # check scale up to 2 nodes
129144 if partition :
130145 result = scheduler_commands .submit_command (
131- "hostname > /shared/hostname.out" , slots = slots_per_instance , partition = partition
146+ "hostname > /shared/hostname.out" , slots = 2 * expected_cpus_per_instance , partition = partition
132147 )
133148 else :
134- result = scheduler_commands .submit_command ("hostname > /shared/hostname.out" , slots = slots_per_instance )
149+ result = scheduler_commands .submit_command (
150+ "hostname > /shared/hostname.out" , slots = 2 * expected_cpus_per_instance
151+ )
135152 job_id = scheduler_commands .assert_job_submitted (result .stdout )
136153 scheduler_commands .wait_job_completed (job_id )
137154 scheduler_commands .assert_job_succeeded (job_id )
0 commit comments