1 /** 2 * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 * SPDX-License-Identifier: Apache-2.0. 4 */ 5 6 package software.amazon.awssdk.crt; 7 8 /** 9 * Utility class for querying system hardware properties 10 */ 11 public class SystemInfo { 12 13 /** 14 * @return active count of processors configured on this system. 15 */ getProcessorCount()16 public static int getProcessorCount() { 17 return processorCount(); 18 } 19 20 /** 21 * @return number of active Cpu groupings on this system. This currently refers to NUMA nodes. 22 */ getCpuGroupCount()23 public static short getCpuGroupCount() { 24 return cpuGroupCount(); 25 } 26 27 /** 28 * Get info on all active Cpus in a Cpu group. 29 * @param groupIdx group index to query. 30 * @return Array of CpuInfo objects configured for this group. This value is never null even if groupIdx was invalid. 31 */ getCpuInfoForGroup(short groupIdx)32 public static CpuInfo[] getCpuInfoForGroup(short groupIdx) { 33 return cpuInfoForGroup(groupIdx); 34 } 35 36 public static class CpuInfo { 37 /** 38 * OS CpuId that can be used for pinning a thread to a specific Cpu 39 */ 40 public final int cpuId; 41 /** 42 * If true, the Cpu is suspected of being virtual. If false, it's likely a hw core. 43 */ 44 public final boolean isSuspectedHyperThread; 45 CpuInfo(int cpuId, boolean isSuspectedHyperThread)46 private CpuInfo(int cpuId, boolean isSuspectedHyperThread) { 47 this.cpuId = cpuId; 48 this.isSuspectedHyperThread = isSuspectedHyperThread; 49 } 50 } 51 52 /* native functions */ processorCount()53 private static native int processorCount(); cpuGroupCount()54 private static native short cpuGroupCount(); cpuInfoForGroup(short groupIdx)55 private static native CpuInfo[] cpuInfoForGroup(short groupIdx); 56 } 57