Skip to content

Commit

Permalink
fix for macos
Browse files Browse the repository at this point in the history
  • Loading branch information
fnrizzi committed Nov 18, 2023
1 parent 17af2f3 commit 68e4bed
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions core/unit_test/TestDeviceAndThreads.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

import unittest
import subprocess
import os #psutil
import platform #psutil

PREFIX = "$<TARGET_FILE_DIR:Kokkos_CoreUnitTest_DeviceAndThreads>"
EXECUTABLE = "$<TARGET_FILE_NAME:Kokkos_CoreUnitTest_DeviceAndThreads>"
Expand All @@ -32,15 +32,18 @@ def GetFlag(flag, *extra_args):

def GetNumThreads(max_threads):
#phys_cores_count = psutil.cpu_count(logical=False)
args = ['nproc', '--all'] #'sysctl', '-n', 'hw.physicalcpu_max']
if os.name == 'nt':
args = []
name = platform.system()
if name == 'Darwin':
args = ['sysctl', '-n', 'hw.physicalcpu_max']
elif name == 'Linux':
args = ['nproc', '--all']
else:
args = ['wmic', 'cpu', 'get', 'NumberOfCores']

result = subprocess.run(args, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
output = result.stdout.decode('utf-8')
phys_cores_count = int(output)
print(phys_cores_count)

looplist = [1] + [i*phys_cores_count for i in [1,2,3,4,5,6,7]]
for x in looplist:
if x >= max_threads:
Expand Down

0 comments on commit 68e4bed

Please sign in to comment.