| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | /*********************************************************************************/ | ||
| 2 | /* Copyright 2009-2024 Barcelona Supercomputing Center */ | ||
| 3 | /* */ | ||
| 4 | /* This file is part of the DLB library. */ | ||
| 5 | /* */ | ||
| 6 | /* DLB is free software: you can redistribute it and/or modify */ | ||
| 7 | /* it under the terms of the GNU Lesser General Public License as published by */ | ||
| 8 | /* the Free Software Foundation, either version 3 of the License, or */ | ||
| 9 | /* (at your option) any later version. */ | ||
| 10 | /* */ | ||
| 11 | /* DLB is distributed in the hope that it will be useful, */ | ||
| 12 | /* but WITHOUT ANY WARRANTY; without even the implied warranty of */ | ||
| 13 | /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ | ||
| 14 | /* GNU Lesser General Public License for more details. */ | ||
| 15 | /* */ | ||
| 16 | /* You should have received a copy of the GNU Lesser General Public License */ | ||
| 17 | /* along with DLB. If not, see <https://www.gnu.org/licenses/>. */ | ||
| 18 | /*********************************************************************************/ | ||
| 19 | |||
| 20 | #include "unique_shmem.h" | ||
| 21 | |||
| 22 | #include "apis/dlb_errors.h" | ||
| 23 | #include "LB_core/spd.h" | ||
| 24 | #include "LB_policies/lewi_mask.h" | ||
| 25 | #include "LB_comm/shmem_procinfo.h" | ||
| 26 | #include "LB_comm/shmem_cpuinfo.h" | ||
| 27 | #include "LB_comm/shmem_async.h" | ||
| 28 | #include "LB_numThreads/numThreads.h" | ||
| 29 | #include "support/atomic.h" | ||
| 30 | #include "support/mask_utils.h" | ||
| 31 | #include "support/debug.h" | ||
| 32 | |||
| 33 | #include <sched.h> | ||
| 34 | #include <unistd.h> | ||
| 35 | #include <assert.h> | ||
| 36 | #include <string.h> | ||
| 37 | #include <stdlib.h> | ||
| 38 | #include <pthread.h> | ||
| 39 | |||
| 40 | static subprocess_descriptor_t spd1; | ||
| 41 | static subprocess_descriptor_t spd2; | ||
| 42 | static cpu_set_t sp1_mask; | ||
| 43 | static cpu_set_t sp2_mask; | ||
| 44 | static interaction_mode_t mode; | ||
| 45 | static atomic_int num_callbacks = 0; | ||
| 46 | |||
| 47 | /* Subprocess 1 callbacks */ | ||
| 48 | 43 | static void sp1_cb_enable_cpu(int cpuid, void *arg) { | |
| 49 | 43 | DLB_ATOMIC_ADD_RLX(&num_callbacks, 1); | |
| 50 |
1/2✓ Branch 0 taken 43 times.
✗ Branch 1 not taken.
|
43 | CPU_SET(cpuid, &sp1_mask); |
| 51 | 43 | } | |
| 52 | |||
| 53 | 5 | static void sp1_cb_disable_cpu(int cpuid, void *arg) { | |
| 54 | 5 | DLB_ATOMIC_ADD_RLX(&num_callbacks, 1); | |
| 55 |
1/2✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
|
5 | CPU_CLR(cpuid, &sp1_mask); |
| 56 | 5 | } | |
| 57 | |||
| 58 | /* Subprocess 2 callbacks */ | ||
| 59 | 44 | static void sp2_cb_enable_cpu(int cpuid, void *arg) { | |
| 60 | 44 | DLB_ATOMIC_ADD_RLX(&num_callbacks, 1); | |
| 61 |
1/2✓ Branch 0 taken 44 times.
✗ Branch 1 not taken.
|
44 | CPU_SET(cpuid, &sp2_mask); |
| 62 | 44 | } | |
| 63 | |||
| 64 | 14 | static void sp2_cb_disable_cpu(int cpuid, void *arg) { | |
| 65 | 14 | DLB_ATOMIC_ADD_RLX(&num_callbacks, 1); | |
| 66 |
1/2✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
|
14 | CPU_CLR(cpuid, &sp2_mask); |
| 67 | 14 | } | |
| 68 | |||
| 69 | 13 | static void wait_for_async_completion(void) { | |
| 70 |
2/2✓ Branch 0 taken 12 times.
✓ Branch 1 taken 1 times.
|
13 | if (mode == MODE_ASYNC) { |
| 71 | 12 | shmem_async_wait_for_completion(spd1.id); | |
| 72 | 12 | shmem_async_wait_for_completion(spd2.id); | |
| 73 | 12 | __sync_synchronize(); | |
| 74 | } | ||
| 75 | 13 | } | |
| 76 | |||
| 77 | 6 | static void wait_for_async_completion_sp(const subprocess_descriptor_t *spd) { | |
| 78 |
2/2✓ Branch 0 taken 3 times.
✓ Branch 1 taken 3 times.
|
6 | if (mode == MODE_ASYNC) { |
| 79 | 3 | shmem_async_wait_for_completion(spd->id); | |
| 80 | 3 | __sync_synchronize(); | |
| 81 | } | ||
| 82 | 6 | } | |
| 83 | |||
| 84 | 15 | static void check_no_requests(void) { | |
| 85 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 15 times.
|
15 | assert( shmem_cpuinfo_testing__get_num_proc_requests() == 0 ); |
| 86 |
2/2✓ Branch 0 taken 60 times.
✓ Branch 1 taken 15 times.
|
75 | for (int i=0; i<4; ++i) { |
| 87 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 60 times.
|
60 | assert( shmem_cpuinfo_testing__get_num_cpu_requests(i) == 0 ); |
| 88 | } | ||
| 89 | 15 | } | |
| 90 | |||
| 91 | 2 | int main( int argc, char **argv ) { | |
| 92 | // This test needs at least room for 4 CPUs | ||
| 93 | enum { SYS_SIZE = 4 }; | ||
| 94 | 2 | mu_init(); | |
| 95 | 2 | mu_testing_set_sys_size(SYS_SIZE); | |
| 96 | |||
| 97 | // Options | ||
| 98 | 2 | char options[64] = "--verbose=shmem --shm-key="; | |
| 99 | 2 | strcat(options, SHMEM_KEY); | |
| 100 | |||
| 101 | // Initialize constant masks for fast reference | ||
| 102 | 2 | const cpu_set_t sys_mask = { .__bits = {0xf} }; /* [1111] */ | |
| 103 | 2 | const cpu_set_t sp1_process_mask = {.__bits={0x3}}; /* [0011] */ | |
| 104 | 2 | const cpu_set_t sp2_process_mask = {.__bits={0xc}}; /* [1100] */ | |
| 105 | |||
| 106 | // Initialize local masks to [1100] and [0011] | ||
| 107 | 2 | memcpy(&sp1_mask, &sp1_process_mask, sizeof(cpu_set_t)); | |
| 108 | 2 | memcpy(&sp2_mask, &sp2_process_mask, sizeof(cpu_set_t)); | |
| 109 | |||
| 110 | // Subprocess 1 init | ||
| 111 | 2 | spd1.id = 111; | |
| 112 | 2 | options_init(&spd1.options, options); | |
| 113 | 2 | debug_init(&spd1.options); | |
| 114 | 2 | memcpy(&spd1.process_mask, &sp1_mask, sizeof(cpu_set_t)); | |
| 115 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
|
2 | assert( shmem_procinfo__init(spd1.id, 0, &spd1.process_mask, NULL, spd1.options.shm_key, |
| 116 | spd1.options.shm_size_multiplier) == DLB_SUCCESS); | ||
| 117 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
|
2 | assert( shmem_cpuinfo__init(spd1.id, 0, &spd1.process_mask, spd1.options.shm_key, |
| 118 | spd1.options.lewi_color) == DLB_SUCCESS); | ||
| 119 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
|
2 | assert( pm_callback_set(&spd1.pm, dlb_callback_enable_cpu, |
| 120 | (dlb_callback_t)sp1_cb_enable_cpu, NULL) == DLB_SUCCESS); | ||
| 121 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
|
2 | assert( pm_callback_set(&spd1.pm, dlb_callback_disable_cpu, |
| 122 | (dlb_callback_t)sp1_cb_disable_cpu, NULL) == DLB_SUCCESS); | ||
| 123 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
|
2 | assert( lewi_mask_Init(&spd1) == DLB_SUCCESS ); |
| 124 | |||
| 125 | // Subprocess 2 init | ||
| 126 | 2 | spd2.id = 222; | |
| 127 | 2 | options_init(&spd2.options, options); | |
| 128 | 2 | memcpy(&spd1.process_mask, &sp1_mask, sizeof(cpu_set_t)); | |
| 129 | 2 | memcpy(&spd2.process_mask, &sp2_mask, sizeof(cpu_set_t)); | |
| 130 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
|
2 | assert( shmem_procinfo__init(spd2.id, 0, &spd2.process_mask, NULL, spd2.options.shm_key, |
| 131 | spd2.options.shm_size_multiplier) == DLB_SUCCESS ); | ||
| 132 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
|
2 | assert( shmem_cpuinfo__init(spd2.id, 0, &spd2.process_mask, spd2.options.shm_key, |
| 133 | spd2.options.lewi_color) == DLB_SUCCESS ); | ||
| 134 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
|
2 | assert( pm_callback_set(&spd2.pm, dlb_callback_enable_cpu, |
| 135 | (dlb_callback_t)sp2_cb_enable_cpu, NULL) == DLB_SUCCESS ); | ||
| 136 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
|
2 | assert( pm_callback_set(&spd2.pm, dlb_callback_disable_cpu, |
| 137 | (dlb_callback_t)sp2_cb_disable_cpu, NULL) == DLB_SUCCESS ); | ||
| 138 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
|
2 | assert( lewi_mask_Init(&spd2) == DLB_SUCCESS ); |
| 139 | |||
| 140 | // Get interaction mode | ||
| 141 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
|
2 | assert( spd1.options.mode == spd2.options.mode ); |
| 142 | 2 | mode = spd1.options.mode; | |
| 143 |
2/2✓ Branch 0 taken 1 times.
✓ Branch 1 taken 1 times.
|
2 | if (mode == MODE_ASYNC) { |
| 144 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
|
1 | assert( shmem_async_init(spd2.id, &spd2.pm, &spd2.process_mask, |
| 145 | spd2.options.shm_key, spd2.options.shm_size_multiplier) == DLB_SUCCESS ); | ||
| 146 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
|
1 | assert( shmem_async_init(spd1.id, &spd1.pm, &spd1.process_mask, |
| 147 | spd1.options.shm_key, spd1.options.shm_size_multiplier) == DLB_SUCCESS ); | ||
| 148 | } | ||
| 149 | |||
| 150 | int err; | ||
| 151 | |||
| 152 | /* Cpu tests */ | ||
| 153 | { | ||
| 154 | // Subprocess 1 wants to acquire CPU 3 | ||
| 155 | 2 | err = lewi_mask_AcquireCpu(&spd1, 3); | |
| 156 |
3/4✓ Branch 0 taken 1 times.
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
|
2 | assert( mode == MODE_ASYNC ? err == DLB_NOTED : err == DLB_NOUPDT ); |
| 157 | |||
| 158 | // Subprocess 2 no longer needs CPU 3 | ||
| 159 |
1/2✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
|
2 | CPU_CLR(3, &sp2_mask); |
| 160 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
|
2 | assert( lewi_mask_LendCpu(&spd2, 3) == DLB_SUCCESS ); |
| 161 | |||
| 162 | // Subprocess 1 receives CPU 3 | ||
| 163 |
2/2✓ Branch 0 taken 1 times.
✓ Branch 1 taken 1 times.
|
2 | if (mode == MODE_POLLING) { |
| 164 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
|
1 | assert( lewi_mask_AcquireCpu(&spd1, 3) == DLB_SUCCESS ); |
| 165 | } else { | ||
| 166 | 1 | wait_for_async_completion(); | |
| 167 | } | ||
| 168 |
3/6✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 2 times.
|
2 | assert( CPU_ISSET(3, &sp1_mask) ); |
| 169 | |||
| 170 | // Subprocess 2 needs again CPU 3 | ||
| 171 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
|
2 | assert( lewi_mask_AcquireCpu(&spd2, 3) == DLB_NOTED ); |
| 172 | |||
| 173 | // Resolve that Subprocess 2 contains CPU 3, and Subprocess 1 doesn't | ||
| 174 |
2/2✓ Branch 0 taken 1 times.
✓ Branch 1 taken 1 times.
|
2 | if (mode == MODE_POLLING) { |
| 175 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
|
1 | assert( lewi_mask_CheckCpuAvailability(&spd2, 3) == DLB_NOTED ); |
| 176 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
|
1 | assert( lewi_mask_ReturnCpu(&spd1, 3) == DLB_SUCCESS ); |
| 177 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
|
1 | assert( lewi_mask_CheckCpuAvailability(&spd2, 3) == DLB_SUCCESS ); |
| 178 | } else { | ||
| 179 | 1 | wait_for_async_completion(); | |
| 180 | } | ||
| 181 |
3/6✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 2 times.
|
2 | assert( CPU_ISSET(3, &sp2_mask) ); |
| 182 |
3/6✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2 times.
|
2 | assert( !CPU_ISSET(3, &sp1_mask) ); |
| 183 | |||
| 184 | // Subprocess 1 no longer needs CPU 1 | ||
| 185 |
1/2✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
|
2 | CPU_CLR(1, &sp1_mask); |
| 186 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
|
2 | assert( lewi_mask_LendCpu(&spd1, 1) == DLB_SUCCESS ); |
| 187 | |||
| 188 | // Subprocess 2 needs CPU 1 | ||
| 189 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
|
2 | assert( lewi_mask_AcquireCpu(&spd2, 1) == DLB_SUCCESS ); |
| 190 | |||
| 191 | // Subprocess 1 reclaims | ||
| 192 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
|
2 | assert( lewi_mask_ReclaimCpu(&spd1, 1) == DLB_NOTED ); |
| 193 | |||
| 194 | // Resolve that Subprocess 1 contains CPU 1, and Subprocess 2 doesn't | ||
| 195 |
2/2✓ Branch 0 taken 1 times.
✓ Branch 1 taken 1 times.
|
2 | if (mode == MODE_POLLING) { |
| 196 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
|
1 | assert( lewi_mask_CheckCpuAvailability(&spd1, 1) == DLB_NOTED ); |
| 197 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
|
1 | assert( lewi_mask_ReturnCpu(&spd2, 1) == DLB_SUCCESS ); |
| 198 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
|
1 | assert( lewi_mask_CheckCpuAvailability(&spd1, 1) == DLB_SUCCESS ); |
| 199 | } else { | ||
| 200 | 1 | wait_for_async_completion(); | |
| 201 | } | ||
| 202 |
3/6✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 2 times.
|
2 | assert( CPU_ISSET(1, &sp1_mask) ); |
| 203 |
3/6✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2 times.
|
2 | assert( !CPU_ISSET(1, &sp2_mask) ); |
| 204 | |||
| 205 | // Test that SP2 receives CPU 1 again if SP1 lends it again | ||
| 206 |
2/2✓ Branch 0 taken 1 times.
✓ Branch 1 taken 1 times.
|
2 | if (mode == MODE_ASYNC) { |
| 207 | // Subprocess 1 lends everything | ||
| 208 | 1 | CPU_ZERO(&sp1_mask); | |
| 209 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
|
1 | assert( lewi_mask_LendCpuMask(&spd1, &sys_mask) == DLB_SUCCESS ); |
| 210 | |||
| 211 | // CPU 1 was still requested by Subprocess 2 | ||
| 212 | 1 | wait_for_async_completion(); | |
| 213 |
3/6✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 1 times.
|
1 | assert( CPU_ISSET(1, &sp2_mask) ); |
| 214 | |||
| 215 | // Subprocess 2 lends CPU 1 | ||
| 216 |
1/2✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
|
1 | CPU_CLR(1, &sp2_mask); |
| 217 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
|
1 | assert( lewi_mask_LendCpu(&spd2, 1) == DLB_SUCCESS ); |
| 218 | |||
| 219 | // Subprocess 1 acquires its mask | ||
| 220 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
|
1 | assert( lewi_mask_AcquireCpuMask(&spd1, &sp1_process_mask) == DLB_SUCCESS ); |
| 221 |
3/6✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 1 times.
|
1 | assert( CPU_ISSET(0, &sp1_mask) ); |
| 222 |
3/6✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 1 times.
|
1 | assert( CPU_ISSET(1, &sp1_mask) ); |
| 223 | } | ||
| 224 | |||
| 225 | 2 | check_no_requests(); | |
| 226 | } | ||
| 227 | |||
| 228 | /* CpuMask tests */ | ||
| 229 | { | ||
| 230 | // Subprocess 1 lends everything | ||
| 231 | 2 | CPU_ZERO(&sp1_mask); | |
| 232 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
|
2 | assert( lewi_mask_LendCpuMask(&spd1, &sys_mask) == DLB_SUCCESS ); |
| 233 | |||
| 234 | // Subprocess 2 acquires everything | ||
| 235 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
|
2 | assert( lewi_mask_AcquireCpuMask(&spd2, &sys_mask) == DLB_SUCCESS ); |
| 236 | |||
| 237 | // Subprocess 1 reclaims its CPUs | ||
| 238 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
|
2 | assert( lewi_mask_ReclaimCpuMask(&spd1, &sp1_process_mask) == DLB_NOTED ); |
| 239 | |||
| 240 | // Subprocess 1 reclaims everything again | ||
| 241 | 2 | err = lewi_mask_ReclaimCpuMask(&spd1, &sys_mask); | |
| 242 |
3/4✓ Branch 0 taken 1 times.
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
|
2 | assert( mode == MODE_ASYNC ? err == DLB_NOUPDT : err == DLB_NOTED ); |
| 243 | |||
| 244 | // Subprocess 2 lends external CPUs | ||
| 245 |
1/2✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
|
2 | CPU_CLR(0, &sp2_mask); |
| 246 |
1/2✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
|
2 | CPU_CLR(1, &sp2_mask); |
| 247 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
|
2 | assert( lewi_mask_LendCpuMask(&spd2, &sp1_process_mask) == DLB_SUCCESS ); |
| 248 | |||
| 249 |
2/2✓ Branch 0 taken 1 times.
✓ Branch 1 taken 1 times.
|
2 | if (mode == MODE_POLLING) { |
| 250 | // Subprocess 1 needs to poll to set guest field | ||
| 251 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
|
1 | assert( lewi_mask_CheckCpuAvailability(&spd1, 0) == DLB_SUCCESS ); |
| 252 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
|
1 | assert( lewi_mask_CheckCpuAvailability(&spd1, 1) == DLB_SUCCESS ); |
| 253 | } else { | ||
| 254 | 1 | wait_for_async_completion(); | |
| 255 | } | ||
| 256 | |||
| 257 | // Check everyone has their CPUs | ||
| 258 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
|
2 | assert( CPU_EQUAL(&sp1_process_mask, &sp1_mask) ); |
| 259 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
|
2 | assert( CPU_EQUAL(&sp2_process_mask, &sp2_mask) ); |
| 260 | 2 | check_no_requests(); | |
| 261 | } | ||
| 262 | |||
| 263 | /* Cpus tests */ | ||
| 264 | { | ||
| 265 | // Subprocess 1 lends CPU 1 | ||
| 266 |
1/2✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
|
2 | CPU_CLR(1, &sp1_mask); |
| 267 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
|
2 | assert( lewi_mask_LendCpu(&spd1, 1) == DLB_SUCCESS ); |
| 268 | |||
| 269 | // Subprocess 2 acquires one CPU | ||
| 270 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
|
2 | assert( lewi_mask_AcquireCpus(&spd2, 1) == DLB_SUCCESS ); |
| 271 |
3/6✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 2 times.
|
2 | assert( CPU_ISSET(1, &sp2_mask) ); |
| 272 | |||
| 273 | // Subprocess 2 acquires one CPU again | ||
| 274 | 2 | err = lewi_mask_AcquireCpus(&spd2, 1); | |
| 275 |
3/4✓ Branch 0 taken 1 times.
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
|
2 | assert( mode == MODE_ASYNC ? err == DLB_NOTED : err == DLB_NOUPDT ); |
| 276 | |||
| 277 | // Subprocess 1 acquires 1 CPU, it should reclaim CPU 1 | ||
| 278 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
|
2 | assert( lewi_mask_AcquireCpus(&spd1, 1) == DLB_NOTED ); |
| 279 |
3/6✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 2 times.
|
2 | assert( CPU_ISSET(1, &sp1_mask) ); |
| 280 | |||
| 281 | // Subprocess 2 returns CPU 1 (async returns by callback) | ||
| 282 |
2/2✓ Branch 0 taken 1 times.
✓ Branch 1 taken 1 times.
|
2 | if (mode == MODE_POLLING) { |
| 283 |
3/6✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 1 times.
|
1 | assert( CPU_ISSET(1, &sp2_mask) ); |
| 284 |
1/2✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
|
1 | CPU_CLR(1, &sp2_mask); |
| 285 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
|
1 | assert( lewi_mask_ReturnCpu(&spd2, 1) == DLB_SUCCESS ); |
| 286 | } | ||
| 287 | |||
| 288 | // Subprocess 1 needs to poll to set guest field | ||
| 289 |
2/2✓ Branch 0 taken 1 times.
✓ Branch 1 taken 1 times.
|
2 | if (mode == MODE_POLLING) { |
| 290 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
|
1 | assert( lewi_mask_CheckCpuAvailability(&spd1, 1) == DLB_SUCCESS ); |
| 291 | } | ||
| 292 | |||
| 293 | // Subprocess 2 no longer wants external CPUs | ||
| 294 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
|
2 | assert( lewi_mask_AcquireCpus(&spd2, 0) == DLB_SUCCESS ); /* general queue */ |
| 295 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
|
2 | assert( lewi_mask_LendCpu(&spd2, 1) == DLB_SUCCESS ); /* CPU queue */ |
| 296 | |||
| 297 | 2 | check_no_requests(); | |
| 298 | 2 | wait_for_async_completion(); | |
| 299 | } | ||
| 300 | |||
| 301 | /* Reset test */ | ||
| 302 | { | ||
| 303 | // Subprocess 2 lends CPU 3 | ||
| 304 |
1/2✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
|
2 | CPU_CLR(3, &sp2_mask); |
| 305 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
|
2 | assert( lewi_mask_LendCpu(&spd2, 3) == DLB_SUCCESS ); |
| 306 | |||
| 307 | // Subprocess 1 acquires one CPU | ||
| 308 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
|
2 | assert( lewi_mask_AcquireCpus(&spd1, 1) == DLB_SUCCESS ); |
| 309 |
4/8✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 2 times.
✗ Branch 8 not taken.
|
2 | assert( CPU_ISSET(3, &sp1_mask) && CPU_COUNT(&sp1_mask) == 3 ); |
| 310 | |||
| 311 | // Subprocess 1 decides to shut down CPU 1 without notifying DLB | ||
| 312 |
1/2✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
|
2 | CPU_CLR(1, &sp1_mask); |
| 313 | |||
| 314 | // Subprocess 1 resets. CPU 1 should not be re-enabled | ||
| 315 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
|
2 | assert( lewi_mask_DisableDLB(&spd1) == DLB_SUCCESS ); |
| 316 |
4/8✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 2 times.
✗ Branch 8 not taken.
|
2 | assert( CPU_ISSET(0, &sp1_mask) && CPU_COUNT(&sp1_mask) == 1 ); |
| 317 | |||
| 318 | // Subprocess 2 recovers CPU 3 | ||
| 319 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
|
2 | assert( lewi_mask_AcquireCpu(&spd2, 3) == DLB_SUCCESS ); |
| 320 |
3/6✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 2 times.
|
2 | assert( CPU_ISSET(3, &sp2_mask) ); |
| 321 | |||
| 322 | // Subprocess 1 enables DLB and CPU 1 | ||
| 323 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
|
2 | assert( lewi_mask_EnableDLB(&spd1) == DLB_SUCCESS ); |
| 324 |
1/2✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
|
2 | CPU_SET(1, &sp1_mask); |
| 325 | |||
| 326 | 2 | check_no_requests(); | |
| 327 | } | ||
| 328 | |||
| 329 | /* Reset test with requested CPUs */ | ||
| 330 |
2/2✓ Branch 0 taken 1 times.
✓ Branch 1 taken 1 times.
|
2 | if (mode == MODE_ASYNC) |
| 331 | { | ||
| 332 | // Subprocess 2 lends CPU 3 | ||
| 333 |
1/2✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
|
1 | CPU_CLR(3, &sp2_mask); |
| 334 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
|
1 | assert( lewi_mask_LendCpu(&spd2, 3) == DLB_SUCCESS ); |
| 335 | |||
| 336 | // Subprocess 1 acquires one CPU | ||
| 337 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
|
1 | assert( lewi_mask_AcquireCpus(&spd1, 1) == DLB_SUCCESS ); |
| 338 |
4/8✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 1 times.
✗ Branch 8 not taken.
|
1 | assert( CPU_ISSET(3, &sp1_mask) && CPU_COUNT(&sp1_mask) == 3 ); |
| 339 | |||
| 340 | // Subprocess 2 requests 1 CPU | ||
| 341 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
|
1 | assert( lewi_mask_AcquireCpus(&spd2, 1) == DLB_NOTED ); |
| 342 | 1 | wait_for_async_completion(); | |
| 343 | |||
| 344 | // Subprocess 1 resets, CPU 3 should go to Subprocess 2 | ||
| 345 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
|
1 | assert( lewi_mask_DisableDLB(&spd1) == DLB_SUCCESS ); |
| 346 | 1 | wait_for_async_completion(); | |
| 347 |
4/8✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 1 times.
✗ Branch 8 not taken.
|
1 | assert( CPU_ISSET(3, &sp2_mask) && CPU_COUNT(&sp2_mask) == 2 ); |
| 348 | |||
| 349 | // Subprocess 1 enables DLB | ||
| 350 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
|
1 | assert( lewi_mask_EnableDLB(&spd1) == DLB_SUCCESS ); |
| 351 | |||
| 352 | 1 | check_no_requests(); | |
| 353 | } | ||
| 354 | |||
| 355 | /* Last borrow optimization test */ | ||
| 356 | { | ||
| 357 | // Subprocess 1 lends everything | ||
| 358 | 2 | CPU_ZERO(&sp1_mask); | |
| 359 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
|
2 | assert( lewi_mask_LendCpuMask(&spd1, &sp1_process_mask) == DLB_SUCCESS ); |
| 360 | |||
| 361 | // Subprocess 2 borrows 1 CPU 3 times | ||
| 362 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
|
2 | assert( lewi_mask_BorrowCpus(&spd2, 1) == DLB_SUCCESS ); |
| 363 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
|
2 | assert( lewi_mask_BorrowCpus(&spd2, 1) == DLB_SUCCESS ); |
| 364 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
|
2 | assert( lewi_mask_BorrowCpus(&spd2, 1) == DLB_NOUPDT ); |
| 365 |
7/14✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 2 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 2 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 2 times.
✗ Branch 12 not taken.
✓ Branch 13 taken 2 times.
✗ Branch 14 not taken.
|
2 | assert( CPU_COUNT(&sp2_mask) == 4 |
| 366 | && CPU_ISSET(0, &sp2_mask) && CPU_ISSET(1, &sp2_mask) ); | ||
| 367 | |||
| 368 | // Subprocess 2 returns borrowed CPUs | ||
| 369 |
1/2✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
|
2 | CPU_CLR(0, &sp2_mask); |
| 370 |
1/2✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
|
2 | CPU_CLR(1, &sp2_mask); |
| 371 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
|
2 | assert( lewi_mask_LendCpuMask(&spd2, &sp1_process_mask) == DLB_SUCCESS ); |
| 372 | |||
| 373 | // Subprocess 1 acquire its CPUs | ||
| 374 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
|
2 | assert( lewi_mask_AcquireCpuMask(&spd1, &sp1_process_mask) == DLB_SUCCESS ); |
| 375 |
6/12✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 2 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 2 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 2 times.
✗ Branch 11 not taken.
|
2 | assert( CPU_ISSET(0, &sp1_mask) && CPU_ISSET(1, &sp1_mask) ); |
| 376 | |||
| 377 | 2 | check_no_requests(); | |
| 378 | } | ||
| 379 | |||
| 380 | /* MaxParallelism */ | ||
| 381 | { | ||
| 382 | // Subprocess 1 lends everything | ||
| 383 | 2 | CPU_ZERO(&sp1_mask); | |
| 384 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
|
2 | assert( lewi_mask_LendCpuMask(&spd1, &sp1_process_mask) == DLB_SUCCESS ); |
| 385 | |||
| 386 | // Subprocess 2 borrows everything | ||
| 387 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
|
2 | assert( lewi_mask_Borrow(&spd2) == DLB_SUCCESS ); |
| 388 |
7/14✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 2 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 2 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 2 times.
✗ Branch 12 not taken.
✓ Branch 13 taken 2 times.
✗ Branch 14 not taken.
|
2 | assert( CPU_COUNT(&sp2_mask) == 4 |
| 389 | && CPU_ISSET(0, &sp2_mask) && CPU_ISSET(1, &sp2_mask) ); | ||
| 390 | |||
| 391 | // Subprocess 1 acquires its CPUs | ||
| 392 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
|
2 | assert( lewi_mask_AcquireCpuMask(&spd1, &sp1_process_mask) == DLB_NOTED ); |
| 393 | |||
| 394 | // Subprocess 2 sets max_parallelism to 2 | ||
| 395 | 2 | lewi_mask_SetMaxParallelism(&spd2, 2); | |
| 396 | |||
| 397 |
2/2✓ Branch 0 taken 1 times.
✓ Branch 1 taken 1 times.
|
2 | if (mode == MODE_ASYNC) { |
| 398 | 1 | wait_for_async_completion(); | |
| 399 | } | ||
| 400 | |||
| 401 | // Both SPs should have their own CPUs | ||
| 402 |
7/14✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 2 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 2 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 2 times.
✗ Branch 12 not taken.
✓ Branch 13 taken 2 times.
✗ Branch 14 not taken.
|
2 | assert( CPU_COUNT(&sp1_mask) == 2 |
| 403 | && CPU_ISSET(0, &sp1_mask) && CPU_ISSET(1, &sp1_mask) ); | ||
| 404 |
7/14✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 2 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 2 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 2 times.
✗ Branch 12 not taken.
✓ Branch 13 taken 2 times.
✗ Branch 14 not taken.
|
2 | assert( CPU_COUNT(&sp2_mask) == 2 |
| 405 | && CPU_ISSET(2, &sp2_mask) && CPU_ISSET(3, &sp2_mask) ); | ||
| 406 | |||
| 407 | // Subprocess 2 removes any previous requests | ||
| 408 |
2/2✓ Branch 0 taken 1 times.
✓ Branch 1 taken 1 times.
|
2 | if (mode == MODE_ASYNC) { |
| 409 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
|
1 | assert( lewi_mask_AcquireCpus(&spd2, 0) == DLB_SUCCESS ); |
| 410 | } | ||
| 411 | |||
| 412 | // Subprocess 1 lends everything | ||
| 413 | 2 | CPU_ZERO(&sp1_mask); | |
| 414 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
|
2 | assert( lewi_mask_LendCpuMask(&spd1, &sp1_process_mask) == DLB_SUCCESS ); |
| 415 | |||
| 416 | // check that the previous lend did not change subprocess 2 mask | ||
| 417 |
7/14✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 2 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 2 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 2 times.
✗ Branch 12 not taken.
✓ Branch 13 taken 2 times.
✗ Branch 14 not taken.
|
2 | assert( CPU_COUNT(&sp2_mask) == 2 |
| 418 | && CPU_ISSET(2, &sp2_mask) && CPU_ISSET(3, &sp2_mask) ); | ||
| 419 | |||
| 420 | // Subprocess 2 borrows everything (can't, max_parallelism still 2) | ||
| 421 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
|
2 | assert( lewi_mask_Borrow(&spd2) == DLB_NOUPDT ); |
| 422 |
7/14✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 2 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 2 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 2 times.
✗ Branch 12 not taken.
✓ Branch 13 taken 2 times.
✗ Branch 14 not taken.
|
2 | assert( CPU_COUNT(&sp2_mask) == 2 |
| 423 | && CPU_ISSET(2, &sp2_mask) && CPU_ISSET(3, &sp2_mask) ); | ||
| 424 | |||
| 425 | // Subprocess 1 acquire its CPUs | ||
| 426 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
|
2 | assert( lewi_mask_AcquireCpuMask(&spd1, &sp1_process_mask) == DLB_SUCCESS ); |
| 427 | |||
| 428 | // Subprocess 2 resets max_parallelism | ||
| 429 | 2 | lewi_mask_UnsetMaxParallelism(&spd2); | |
| 430 | |||
| 431 | 2 | check_no_requests(); | |
| 432 | } | ||
| 433 | |||
| 434 | /* Test CpusInMask */ | ||
| 435 | { | ||
| 436 | // Construct a mask of only 1 CPU from subprocess 1, and all from subprocess 2 | ||
| 437 | cpu_set_t mask; | ||
| 438 | 2 | CPU_ZERO(&mask); | |
| 439 |
1/2✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
|
2 | CPU_SET(0, &mask); |
| 440 |
2/2✓ Branch 0 taken 32 times.
✓ Branch 1 taken 2 times.
|
34 | CPU_OR(&mask, &mask, &sp2_mask); |
| 441 | |||
| 442 | // Subprocess 1 lends everything | ||
| 443 | 2 | CPU_ZERO(&sp1_mask); | |
| 444 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
|
2 | assert( lewi_mask_LendCpuMask(&spd1, &sp1_process_mask) == DLB_SUCCESS ); |
| 445 | |||
| 446 | // Subprocess 2 lends 1 CPU | ||
| 447 |
1/2✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
|
2 | CPU_CLR(2, &sp2_mask); |
| 448 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
|
2 | assert( lewi_mask_LendCpu(&spd2, 2) == DLB_SUCCESS ); |
| 449 | |||
| 450 | // Subprocess 2 tries to acquire 1 CPU from the auxiliar mask [0,2,3] (it should prioritize [2,3]) | ||
| 451 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
|
2 | assert( lewi_mask_AcquireCpusInMask(&spd2, 1, &mask) == DLB_SUCCESS ); |
| 452 |
7/14✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 2 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 2 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 2 times.
✗ Branch 12 not taken.
✓ Branch 13 taken 2 times.
✗ Branch 14 not taken.
|
2 | assert( CPU_COUNT(&sp2_mask) == 2 |
| 453 | && CPU_ISSET(2, &sp2_mask) && CPU_ISSET(3, &sp2_mask)); | ||
| 454 | |||
| 455 | // Subprocess 2 lends 1 CPU, again | ||
| 456 |
1/2✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
|
2 | CPU_CLR(2, &sp2_mask); |
| 457 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
|
2 | assert( lewi_mask_LendCpu(&spd2, 2) == DLB_SUCCESS ); |
| 458 | |||
| 459 | // Subprocess 2 tries to acquire 4 CPUs from the auxiliar mask [0,2,3] | ||
| 460 | 2 | err = lewi_mask_AcquireCpusInMask(&spd2, 4, &mask); | |
| 461 |
3/4✓ Branch 0 taken 1 times.
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
|
2 | assert( mode == MODE_ASYNC ? err == DLB_NOTED : err == DLB_SUCCESS ); |
| 462 |
10/20✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 2 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 2 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 2 times.
✗ Branch 12 not taken.
✓ Branch 13 taken 2 times.
✗ Branch 14 not taken.
✓ Branch 15 taken 2 times.
✗ Branch 16 not taken.
✓ Branch 17 taken 2 times.
✗ Branch 18 not taken.
✓ Branch 19 taken 2 times.
✗ Branch 20 not taken.
|
2 | assert( CPU_COUNT(&sp2_mask) == 3 |
| 463 | && CPU_ISSET(0, &sp2_mask) && CPU_ISSET(2, &sp2_mask) && CPU_ISSET(3, &sp2_mask)); | ||
| 464 | |||
| 465 | // Subprocess 2 removes any previous requests | ||
| 466 |
2/2✓ Branch 0 taken 1 times.
✓ Branch 1 taken 1 times.
|
2 | if (mode == MODE_ASYNC) { |
| 467 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
|
1 | assert( lewi_mask_AcquireCpus(&spd2, 0) == DLB_SUCCESS ); |
| 468 | } | ||
| 469 | |||
| 470 | // Subprocess 2 lends everything (0 first, and 2-3 later) | ||
| 471 | 2 | CPU_ZERO(&sp2_mask); | |
| 472 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
|
2 | assert( lewi_mask_LendCpu(&spd2, 0) == DLB_SUCCESS ); |
| 473 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
|
2 | assert( lewi_mask_LendCpuMask(&spd2, &sp2_process_mask) == DLB_SUCCESS ); |
| 474 | |||
| 475 | // Subprocess 2 borrows 1 CPU (twice) from the auxiliar mask [0,2,3] (it should prioritize [2,3]) | ||
| 476 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
|
2 | assert( lewi_mask_BorrowCpusInMask(&spd2, 1, &mask) == DLB_SUCCESS ); |
| 477 |
4/8✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 2 times.
✗ Branch 8 not taken.
|
2 | assert( CPU_COUNT(&sp2_mask) == 1 && CPU_ISSET(2, &sp2_mask)); |
| 478 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
|
2 | assert( lewi_mask_BorrowCpusInMask(&spd2, 1, &mask) == DLB_SUCCESS ); |
| 479 |
7/14✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 2 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 2 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 2 times.
✗ Branch 12 not taken.
✓ Branch 13 taken 2 times.
✗ Branch 14 not taken.
|
2 | assert( CPU_COUNT(&sp2_mask) == 2 |
| 480 | && CPU_ISSET(2, &sp2_mask) && CPU_ISSET(3, &sp2_mask)); | ||
| 481 | |||
| 482 | // Subprocess 1 acquire its CPUs | ||
| 483 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
|
2 | assert( lewi_mask_AcquireCpuMask(&spd1, &sp1_process_mask) == DLB_SUCCESS ); |
| 484 |
7/14✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 2 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 2 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 2 times.
✗ Branch 12 not taken.
✓ Branch 13 taken 2 times.
✗ Branch 14 not taken.
|
2 | assert( CPU_COUNT(&sp1_mask) == 2 |
| 485 | && CPU_ISSET(0, &sp1_mask) && CPU_ISSET(1, &sp1_mask)); | ||
| 486 | |||
| 487 | // Both SPs should have their own CPUs | ||
| 488 |
7/14✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 2 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 2 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 2 times.
✗ Branch 12 not taken.
✓ Branch 13 taken 2 times.
✗ Branch 14 not taken.
|
2 | assert( CPU_COUNT(&sp1_mask) == 2 |
| 489 | && CPU_ISSET(0, &sp1_mask) && CPU_ISSET(1, &sp1_mask) ); | ||
| 490 |
7/14✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 2 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 2 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 2 times.
✗ Branch 12 not taken.
✓ Branch 13 taken 2 times.
✗ Branch 14 not taken.
|
2 | assert( CPU_COUNT(&sp2_mask) == 2 |
| 491 | && CPU_ISSET(2, &sp2_mask) && CPU_ISSET(3, &sp2_mask) ); | ||
| 492 | |||
| 493 | 2 | check_no_requests(); | |
| 494 | } | ||
| 495 | |||
| 496 | /* Into / Out of Blocking Calls */ | ||
| 497 | { | ||
| 498 | // These functions get the CPU id from sched_getcpu() | ||
| 499 | // Force binding to CPU 0 or skip test | ||
| 500 | cpu_set_t mask; | ||
| 501 | 2 | mu_parse_mask("0", &mask); | |
| 502 | 2 | sched_setaffinity(0, sizeof(cpu_set_t), &mask); | |
| 503 |
1/2✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
|
2 | if (sched_getcpu() == 0) { |
| 504 | |||
| 505 | // Enable --lewi-keep-one-cpu | ||
| 506 | 2 | spd1.options.lewi_keep_cpu_on_blocking_call = true; | |
| 507 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
|
2 | assert( lewi_mask_IntoBlockingCall(&spd1) == DLB_NOUPDT ); |
| 508 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
|
2 | assert( lewi_mask_OutOfBlockingCall(&spd1) == DLB_NOUPDT ); |
| 509 | |||
| 510 | // Disable --lewi-keep-one-cpu | ||
| 511 | 2 | spd1.options.lewi_keep_cpu_on_blocking_call = false; | |
| 512 | 2 | spd2.options.lewi_keep_cpu_on_blocking_call = false; | |
| 513 | |||
| 514 | /* No conflict */ | ||
| 515 | { | ||
| 516 | // Subprocess 1 enters a blocking call | ||
| 517 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
|
2 | assert( lewi_mask_IntoBlockingCall(&spd1) == DLB_SUCCESS ); |
| 518 | |||
| 519 | // Subprocess 2 may borrow CPU 0 | ||
| 520 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
|
2 | assert( lewi_mask_BorrowCpu(&spd2, 0) == DLB_SUCCESS ); |
| 521 |
4/8✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 2 times.
✗ Branch 8 not taken.
|
2 | assert( CPU_COUNT(&sp2_mask) == 3 && CPU_ISSET(0, &sp2_mask) ); |
| 522 | |||
| 523 | // Subprocess 2 lends CPU 0 | ||
| 524 |
1/2✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
|
2 | CPU_CLR(0, &sp2_mask); |
| 525 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
|
2 | assert( lewi_mask_LendCpu(&spd2, 0) == DLB_SUCCESS ); |
| 526 | |||
| 527 | // Subprocess 1 leaves the blocking call | ||
| 528 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
|
2 | assert( lewi_mask_OutOfBlockingCall(&spd1) == DLB_SUCCESS ); |
| 529 | } | ||
| 530 | |||
| 531 | /* Subprocess 1 reclaims */ | ||
| 532 | { | ||
| 533 | // Subprocess 1 enters a blocking call | ||
| 534 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
|
2 | assert( lewi_mask_IntoBlockingCall(&spd1) == DLB_SUCCESS ); |
| 535 | |||
| 536 | // Subprocess 2 may borrow CPU 0 | ||
| 537 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
|
2 | assert( lewi_mask_BorrowCpu(&spd2, 0) == DLB_SUCCESS ); |
| 538 |
4/8✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 2 times.
✗ Branch 8 not taken.
|
2 | assert( CPU_COUNT(&sp2_mask) == 3 && CPU_ISSET(0, &sp2_mask) ); |
| 539 | |||
| 540 | // Subprocess 1 leaves the blocking call, CPU 0 is reclaimed | ||
| 541 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
|
2 | assert( lewi_mask_OutOfBlockingCall(&spd1) == DLB_NOTED ); |
| 542 | |||
| 543 | // Subprocesses 2 needs to poll | ||
| 544 |
2/2✓ Branch 0 taken 1 times.
✓ Branch 1 taken 1 times.
|
2 | if (mode == MODE_POLLING) { |
| 545 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
|
1 | assert( lewi_mask_CheckCpuAvailability(&spd1, 0) == DLB_NOTED ); |
| 546 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
|
1 | assert( lewi_mask_ReturnCpu(&spd2, 0) == DLB_SUCCESS ); |
| 547 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
|
1 | assert( lewi_mask_CheckCpuAvailability(&spd1, 0) == DLB_SUCCESS ); |
| 548 | } else { | ||
| 549 | 1 | wait_for_async_completion(); | |
| 550 | } | ||
| 551 | |||
| 552 | // Both SPs should have their own CPUs | ||
| 553 |
7/14✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 2 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 2 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 2 times.
✗ Branch 12 not taken.
✓ Branch 13 taken 2 times.
✗ Branch 14 not taken.
|
2 | assert( CPU_COUNT(&sp1_mask) == 2 |
| 554 | && CPU_ISSET(0, &sp1_mask) && CPU_ISSET(1, &sp1_mask) ); | ||
| 555 |
7/14✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 2 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 2 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 2 times.
✗ Branch 12 not taken.
✓ Branch 13 taken 2 times.
✗ Branch 14 not taken.
|
2 | assert( CPU_COUNT(&sp2_mask) == 2 |
| 556 | && CPU_ISSET(2, &sp2_mask) && CPU_ISSET(3, &sp2_mask) ); | ||
| 557 | |||
| 558 | // Subprocesses 2 removes the request over CPU 0 | ||
| 559 |
2/2✓ Branch 0 taken 1 times.
✓ Branch 1 taken 1 times.
|
2 | if (mode == MODE_ASYNC) { |
| 560 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
|
1 | assert( lewi_mask_LendCpu(&spd2, 0) == DLB_SUCCESS ); |
| 561 | } | ||
| 562 | } | ||
| 563 | |||
| 564 | /* MPI with a non-owned CPU, no conflict */ | ||
| 565 | { | ||
| 566 | // Subprocess 1 lends CPU 0 | ||
| 567 |
1/2✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
|
2 | CPU_CLR(0, &sp1_mask); |
| 568 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
|
2 | assert( lewi_mask_LendCpu(&spd1, 0) == DLB_SUCCESS ); |
| 569 | |||
| 570 | // Subprocess 2 borrows CPU 0 | ||
| 571 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
|
2 | assert( lewi_mask_BorrowCpu(&spd2, 0) == DLB_SUCCESS ); |
| 572 |
4/8✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 2 times.
✗ Branch 8 not taken.
|
2 | assert( CPU_COUNT(&sp2_mask) == 3 && CPU_ISSET(0, &sp2_mask) ); |
| 573 | |||
| 574 | // Subprocess 2 enters a blocking call (with CPU 0) | ||
| 575 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
|
2 | assert( lewi_mask_IntoBlockingCall(&spd2) == DLB_SUCCESS ); |
| 576 | |||
| 577 | // Subprocess 1 may borrow CPU 0 | ||
| 578 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
|
2 | assert( lewi_mask_BorrowCpu(&spd1, 0) == DLB_SUCCESS ); |
| 579 |
4/8✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 2 times.
✗ Branch 8 not taken.
|
2 | assert( CPU_COUNT(&sp1_mask) == 2 && CPU_ISSET(0, &sp1_mask) ); |
| 580 | |||
| 581 | // Subprocess 1 lends CPU 0 | ||
| 582 |
1/2✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
|
2 | CPU_CLR(0, &sp1_mask); |
| 583 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
|
2 | assert( lewi_mask_LendCpu(&spd1, 0) == DLB_SUCCESS ); |
| 584 | |||
| 585 | // Subprocess 2 leaves the blocking call | ||
| 586 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
|
2 | assert( lewi_mask_OutOfBlockingCall(&spd2) == DLB_SUCCESS ); |
| 587 | |||
| 588 | // Subprocess 2 lends CPU 0 | ||
| 589 |
1/2✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
|
2 | CPU_CLR(0, &sp2_mask); |
| 590 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
|
2 | assert( lewi_mask_LendCpu(&spd2, 0) == DLB_SUCCESS ); |
| 591 | |||
| 592 | // Subprocess 1 acquires CPU 0 | ||
| 593 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
|
2 | assert( lewi_mask_AcquireCpu(&spd1, 0) == DLB_SUCCESS ); |
| 594 | |||
| 595 |
2/2✓ Branch 0 taken 1 times.
✓ Branch 1 taken 1 times.
|
2 | if (mode == MODE_ASYNC) { |
| 596 | 1 | wait_for_async_completion(); | |
| 597 | } | ||
| 598 | |||
| 599 | // Both SPs should have their own CPUs | ||
| 600 |
7/14✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 2 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 2 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 2 times.
✗ Branch 12 not taken.
✓ Branch 13 taken 2 times.
✗ Branch 14 not taken.
|
2 | assert( CPU_COUNT(&sp1_mask) == 2 |
| 601 | && CPU_ISSET(0, &sp1_mask) && CPU_ISSET(1, &sp1_mask) ); | ||
| 602 |
7/14✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 2 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 2 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 2 times.
✗ Branch 12 not taken.
✓ Branch 13 taken 2 times.
✗ Branch 14 not taken.
|
2 | assert( CPU_COUNT(&sp2_mask) == 2 |
| 603 | && CPU_ISSET(2, &sp2_mask) && CPU_ISSET(3, &sp2_mask) ); | ||
| 604 | } | ||
| 605 | |||
| 606 | /* MPI with a non-owned CPU, Subprocess 1 reclaims */ | ||
| 607 | { | ||
| 608 | // Subprocess 1 lends CPU 0 | ||
| 609 |
1/2✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
|
2 | CPU_CLR(0, &sp1_mask); |
| 610 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
|
2 | assert( lewi_mask_LendCpu(&spd1, 0) == DLB_SUCCESS ); |
| 611 | |||
| 612 | // Subprocess 2 borrows CPU 0 | ||
| 613 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
|
2 | assert( lewi_mask_BorrowCpu(&spd2, 0) == DLB_SUCCESS ); |
| 614 |
4/8✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 2 times.
✗ Branch 8 not taken.
|
2 | assert( CPU_COUNT(&sp2_mask) == 3 && CPU_ISSET(0, &sp2_mask) ); |
| 615 | |||
| 616 | // Subprocess 2 enters a blocking call (with CPU 0) | ||
| 617 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
|
2 | assert( lewi_mask_IntoBlockingCall(&spd2) == DLB_SUCCESS ); |
| 618 | |||
| 619 | // Subprocess 1 acquires CPU 0 | ||
| 620 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
|
2 | assert( lewi_mask_AcquireCpu(&spd1, 0) == DLB_SUCCESS ); |
| 621 |
4/8✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 2 times.
✗ Branch 8 not taken.
|
2 | assert( CPU_COUNT(&sp1_mask) == 2 && CPU_ISSET(0, &sp1_mask) ); |
| 622 | |||
| 623 | // Subprocess 2 leaves the blocking call | ||
| 624 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
|
2 | assert( lewi_mask_OutOfBlockingCall(&spd2) == DLB_NOUPDT ); |
| 625 | |||
| 626 |
2/2✓ Branch 0 taken 1 times.
✓ Branch 1 taken 1 times.
|
2 | if (mode == MODE_POLLING) { |
| 627 | // Subprocess 2 needs to poll | ||
| 628 |
4/8✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 1 times.
✗ Branch 8 not taken.
|
1 | assert( CPU_COUNT(&sp2_mask) == 3 && CPU_ISSET(0, &sp2_mask) ); |
| 629 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
|
1 | assert( lewi_mask_ReturnCpu(&spd2, 0) == DLB_SUCCESS ); |
| 630 |
4/8✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✓ Branch 6 taken 1 times.
✓ Branch 7 taken 1 times.
✗ Branch 8 not taken.
|
1 | assert( CPU_COUNT(&sp2_mask) == 2 && !CPU_ISSET(0, &sp2_mask) ); |
| 631 | } else { | ||
| 632 | 1 | wait_for_async_completion(); | |
| 633 | } | ||
| 634 | |||
| 635 | // Both SPs should have their own CPUs | ||
| 636 |
7/14✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 2 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 2 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 2 times.
✗ Branch 12 not taken.
✓ Branch 13 taken 2 times.
✗ Branch 14 not taken.
|
2 | assert( CPU_COUNT(&sp1_mask) == 2 |
| 637 | && CPU_ISSET(0, &sp1_mask) && CPU_ISSET(1, &sp1_mask) ); | ||
| 638 |
7/14✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 2 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 2 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 2 times.
✗ Branch 12 not taken.
✓ Branch 13 taken 2 times.
✗ Branch 14 not taken.
|
2 | assert( CPU_COUNT(&sp2_mask) == 2 |
| 639 | && CPU_ISSET(2, &sp2_mask) && CPU_ISSET(3, &sp2_mask) ); | ||
| 640 | |||
| 641 | // Subprocesses 2 removes the request over CPU 0 | ||
| 642 |
2/2✓ Branch 0 taken 1 times.
✓ Branch 1 taken 1 times.
|
2 | if (mode == MODE_ASYNC) { |
| 643 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
|
1 | assert( lewi_mask_LendCpu(&spd2, 0) == DLB_SUCCESS ); |
| 644 | } | ||
| 645 | } | ||
| 646 | } else { | ||
| 647 | ✗ | printf("Skipping Into / Out of Blocking Calls tests (1 CPU)\n"); | |
| 648 | } | ||
| 649 | } | ||
| 650 | |||
| 651 | // Finalize subprocess 1 | ||
| 652 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
|
2 | assert( lewi_mask_Finalize(&spd1) == DLB_SUCCESS ); |
| 653 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
|
2 | assert( shmem_cpuinfo__finalize(spd1.id, spd1.options.shm_key, spd1.options.lewi_color) |
| 654 | == DLB_SUCCESS ); | ||
| 655 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
|
2 | assert( shmem_procinfo__finalize(spd1.id, false, spd1.options.shm_key, |
| 656 | spd1.options.shm_size_multiplier) == DLB_SUCCESS ); | ||
| 657 |
2/2✓ Branch 0 taken 1 times.
✓ Branch 1 taken 1 times.
|
2 | if (mode == MODE_ASYNC) { |
| 658 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
|
1 | assert( shmem_async_finalize(spd1.id) == DLB_SUCCESS ); |
| 659 | } | ||
| 660 | |||
| 661 | /* Test acquiring unregistered CPUs */ | ||
| 662 | { | ||
| 663 | // Subprocess 2 lends CPU 3 | ||
| 664 |
1/2✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
|
2 | CPU_CLR(3, &sp2_mask); |
| 665 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
|
2 | assert( lewi_mask_LendCpu(&spd2, 3) == DLB_SUCCESS ); |
| 666 | |||
| 667 | // Subprocess 2 acquires everything | ||
| 668 | // - Mask operations will return DLB_SUCCESS in polling mode, ignoring disabled CPUs. | ||
| 669 | // - In async mode, they return DLB_NOTED because disabled CPUs are added as requests. | ||
| 670 | 2 | err = lewi_mask_AcquireCpuMask(&spd2, &sys_mask); | |
| 671 |
3/4✓ Branch 0 taken 1 times.
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
|
2 | if (mode == MODE_POLLING) assert( err == DLB_SUCCESS ); |
| 672 |
3/4✓ Branch 0 taken 1 times.
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
|
2 | if (mode == MODE_ASYNC) assert( err == DLB_NOTED ); |
| 673 | |||
| 674 | // Subprocess 2 acquires CPU 0 | ||
| 675 | // - In polling mode, acquiring a disabled CPU must return DLB_ERR_PERM. | ||
| 676 | // - In async mode, a request will be added. | ||
| 677 | 2 | err = lewi_mask_AcquireCpu(&spd2, 0); | |
| 678 |
3/4✓ Branch 0 taken 1 times.
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
|
2 | if (mode == MODE_POLLING) assert( err == DLB_ERR_PERM ); |
| 679 |
3/4✓ Branch 0 taken 1 times.
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
|
2 | if (mode == MODE_ASYNC) assert( err == DLB_NOTED ); |
| 680 | |||
| 681 | // Subprocess 2 should have its own CPUs | ||
| 682 |
7/14✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 2 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 2 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 2 times.
✗ Branch 12 not taken.
✓ Branch 13 taken 2 times.
✗ Branch 14 not taken.
|
2 | assert( CPU_COUNT(&sp2_mask) == 2 |
| 683 | && CPU_ISSET(2, &sp2_mask) && CPU_ISSET(3, &sp2_mask) ); | ||
| 684 | |||
| 685 | // Subprocess 2 lends CPU 3 | ||
| 686 |
1/2✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
|
2 | CPU_CLR(3, &sp2_mask); |
| 687 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
|
2 | assert( lewi_mask_LendCpu(&spd2, 3) == DLB_SUCCESS ); |
| 688 | |||
| 689 | // Subprocess 2 reclaims everything | ||
| 690 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
|
2 | assert( lewi_mask_ReclaimCpuMask(&spd2, &sys_mask ) == DLB_SUCCESS ); |
| 691 | |||
| 692 | // Subprocess 2 should have its own CPUs | ||
| 693 |
7/14✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 2 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 2 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 2 times.
✗ Branch 12 not taken.
✓ Branch 13 taken 2 times.
✗ Branch 14 not taken.
|
2 | assert( CPU_COUNT(&sp2_mask) == 2 |
| 694 | && CPU_ISSET(2, &sp2_mask) && CPU_ISSET(3, &sp2_mask) ); | ||
| 695 | } | ||
| 696 | |||
| 697 | // Finalize subprocess 2 | ||
| 698 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
|
2 | assert( lewi_mask_Finalize(&spd2) == DLB_SUCCESS ); |
| 699 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
|
2 | assert( shmem_cpuinfo__finalize(spd2.id, spd2.options.shm_key, spd2.options.lewi_color) |
| 700 | == DLB_SUCCESS ); | ||
| 701 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
|
2 | assert( shmem_procinfo__finalize(spd2.id, false, spd2.options.shm_key, |
| 702 | spd2.options.shm_size_multiplier) == DLB_SUCCESS ); | ||
| 703 |
2/2✓ Branch 0 taken 1 times.
✓ Branch 1 taken 1 times.
|
2 | if (mode == MODE_ASYNC) { |
| 704 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
|
1 | assert( shmem_async_finalize(spd2.id) == DLB_SUCCESS ); |
| 705 | } | ||
| 706 | |||
| 707 | /* Tests lending unregistered CPUs */ | ||
| 708 | { | ||
| 709 | // Init with empty mask | ||
| 710 | 2 | CPU_ZERO(&spd1.process_mask); | |
| 711 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
|
2 | assert( shmem_procinfo__init(spd1.id, 0, &spd1.process_mask, NULL, spd1.options.shm_key, |
| 712 | spd1.options.shm_size_multiplier) == DLB_SUCCESS); | ||
| 713 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
|
2 | assert( shmem_cpuinfo__init(spd1.id, 0, &spd1.process_mask, spd1.options.shm_key, |
| 714 | spd1.options.lewi_color) == DLB_SUCCESS); | ||
| 715 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
|
2 | assert( lewi_mask_Init(&spd1) == DLB_SUCCESS ); |
| 716 |
2/2✓ Branch 0 taken 1 times.
✓ Branch 1 taken 1 times.
|
2 | if (mode == MODE_ASYNC) { |
| 717 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
|
1 | assert( shmem_async_init(spd1.id, &spd1.pm, &spd1.process_mask, |
| 718 | spd1.options.shm_key, spd1.options.shm_size_multiplier) == DLB_SUCCESS ); | ||
| 719 | } | ||
| 720 | |||
| 721 | // Lend mask | ||
| 722 | 2 | DLB_ATOMIC_ST(&num_callbacks, 0); | |
| 723 | 2 | lewi_mask_Lend(&spd1); | |
| 724 | 2 | wait_for_async_completion_sp(&spd1); | |
| 725 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
|
2 | assert( DLB_ATOMIC_LD(&num_callbacks) == 0 ); |
| 726 | |||
| 727 | // IntoBlockingCall | ||
| 728 | 2 | lewi_mask_IntoBlockingCall(&spd1); | |
| 729 | 2 | wait_for_async_completion_sp(&spd1); | |
| 730 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
|
2 | assert( DLB_ATOMIC_LD(&num_callbacks) == 0 ); |
| 731 | |||
| 732 | // OutOfBlockingCall | ||
| 733 | 2 | lewi_mask_OutOfBlockingCall(&spd1); | |
| 734 | 2 | wait_for_async_completion_sp(&spd1); | |
| 735 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
|
2 | assert( DLB_ATOMIC_LD(&num_callbacks) == 0 ); |
| 736 | |||
| 737 | // Finalize | ||
| 738 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
|
2 | assert( lewi_mask_Finalize(&spd1) == DLB_SUCCESS ); |
| 739 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
|
2 | assert( shmem_cpuinfo__finalize(spd1.id, spd1.options.shm_key, spd1.options.lewi_color) |
| 740 | == DLB_SUCCESS ); | ||
| 741 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
|
2 | assert( shmem_procinfo__finalize(spd1.id, false, spd1.options.shm_key, |
| 742 | spd1.options.shm_size_multiplier) == DLB_SUCCESS ); | ||
| 743 |
2/2✓ Branch 0 taken 1 times.
✓ Branch 1 taken 1 times.
|
2 | if (mode == MODE_ASYNC) { |
| 744 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
|
1 | assert( shmem_async_finalize(spd1.id) == DLB_SUCCESS ); |
| 745 | } | ||
| 746 | } | ||
| 747 | |||
| 748 | 2 | mu_finalize(); | |
| 749 | |||
| 750 | 2 | return 0; | |
| 751 | } | ||
| 752 |