Skip to content

Commit

Permalink
Added code to detect micro architecture
Browse files Browse the repository at this point in the history
- zlinux version detection
- add tests

Signed-off-by: Anna Babu Palathingal <anna.bp@ibm.com>
  • Loading branch information
annaibm committed Dec 6, 2023
1 parent 21c9cfc commit 8be8ff7
Show file tree
Hide file tree
Showing 4 changed files with 120 additions and 4 deletions.
68 changes: 68 additions & 0 deletions examples/platformRequirements/playlist.xml
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,76 @@
<platformRequirements>^arch.x86</platformRequirements>
</platformRequirementsList>
</test>
<!-- Test for skylake microarchitecture -->
<test>
<testCaseName>test_microarchitecture_detection_skylake</testCaseName>
<command>echo "test microarchitecture detection for skylake"; \
$(TEST_STATUS)</command>
<platformRequirementsList>
<platformRequirements>skylake</platformRequirements>
</platformRequirementsList>
</test>

<!-- Test for z15.t01 microarchitecture -->
<test>
<testCaseName>test_microarchitecture_detection_z15_t01</testCaseName>
<command>echo "test microarchitecture detection for z15.t01"; \
$(TEST_STATUS)</command>
<platformRequirementsList>
<platformRequirements>z15.t01</platformRequirements>
</platformRequirementsList>
</test>

<!-- Test for z15.t02 microarchitecture -->
<test>
<testCaseName>test_microarchitecture_detection_z15_t02</testCaseName>
<command>echo "test microarchitecture detection for z15.t02"; \
$(TEST_STATUS)</command>
<platformRequirementsList>
<platformRequirements>z15.t02</platformRequirements>
</platformRequirementsList>
</test>

<!-- Test for z14.zr1 microarchitecture -->
<test>
<testCaseName>test_microarchitecture_detection_z14_zr1</testCaseName>
<command>echo "test microarchitecture detection for z14.zr1"; \
$(TEST_STATUS)</command>
<platformRequirementsList>
<platformRequirements>z14.zr1</platformRequirements>
</platformRequirementsList>
</test>

<!-- Test for z14 microarchitecture -->
<test>
<testCaseName>test_microarchitecture_detection_z14</testCaseName>
<command>echo "test microarchitecture detection for z14"; \
$(TEST_STATUS)</command>
<platformRequirementsList>
<platformRequirements>z14</platformRequirements>
</platformRequirementsList>
</test>

<!-- Test for z13s microarchitecture -->
<test>
<testCaseName>test_microarchitecture_detection_z13s</testCaseName>
<command>echo "test microarchitecture detection for z13s"; \
$(TEST_STATUS)</command>
<platformRequirementsList>
<platformRequirements>z13s</platformRequirements>
</platformRequirementsList>
</test>

<!-- Test for z13 microarchitecture -->
<test>
<testCaseName>test_microarchitecture_detection_z13</testCaseName>
<command>echo "test microarchitecture detection for z13"; \
$(TEST_STATUS)</command>
<platformRequirementsList>
<platformRequirements>z13</platformRequirements>
</platformRequirementsList>
</test>

<testCaseName>test_bits_64</testCaseName>
<command>echo "test bits.64"; \
$(TEST_STATUS)</command>
Expand Down
2 changes: 1 addition & 1 deletion makeGen.mk
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ autoconfig:
perl scripts$(D)configure.pl

autogen: autoconfig
${TEST_JDK_HOME}/bin/java -cp $(Q)$(TKG_JAR)$(P)$(JSON_SIMPLE)$(Q) org.testKitGen.MainRunner --mode=$(MODE) --spec=$(SPEC) --microArch=$(MICROARCH) --osLabel=$(Q)$(OS_LABEL)$(Q) --jdkVersion=$(JDK_VERSION) --impl=$(JDK_IMPL) --vendor=$(Q)$(JDK_VENDOR)$(Q) --buildList=${BUILD_LIST} --iterations=$(TKG_ITERATIONS) --aotIterations=$(AOT_ITERATIONS) --testFlag=$(TEST_FLAG) --testTarget=$(TESTTARGET) --testList=$(TESTLIST) --numOfMachines=$(NUM_MACHINES) --testTime=$(TEST_TIME) --TRSSURL=$(TRSS_URL) $(OPTS)
${TEST_JDK_HOME}/bin/java -cp $(Q)$(TKG_JAR)$(P)$(JSON_SIMPLE)$(Q) org.testKitGen.MainRunner --mode=$(MODE) --spec=$(SPEC) --microArch=$(Q)$(MICROARCH)$(Q) --osLabel=$(Q)$(OS_LABEL)$(Q) --jdkVersion=$(JDK_VERSION) --impl=$(JDK_IMPL) --vendor=$(Q)$(JDK_VENDOR)$(Q) --buildList=${BUILD_LIST} --iterations=$(TKG_ITERATIONS) --aotIterations=$(AOT_ITERATIONS) --testFlag=$(TEST_FLAG) --testTarget=$(TESTTARGET) --testList=$(TESTLIST) --numOfMachines=$(NUM_MACHINES) --testTime=$(TEST_TIME) --TRSSURL=$(TRSS_URL) $(OPTS)

AUTOGEN_FILES = $(wildcard $(CURRENT_DIR)$(D)jvmTest.mk)
AUTOGEN_FILES += $(wildcard $(CURRENT_DIR)$(D)machineConfigure.mk)
Expand Down
24 changes: 24 additions & 0 deletions scripts/testTKG/test_platformRequirements.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,30 @@ def run_test():
if 'test_not_os_linux_ubuntu20plus_0' not in passed:
skipped.add('test_not_os_linux_ubuntu20plus_0')

micro_arch = re.search(r"set MICROARCH to (.*)", stdout)
print("Output:", stdout)
if micro_arch is not None:
micro_arch = micro_arch.group(1)
label_str = os_label.split(".")
# micro_arch example: skylake
try:
if label_str[0] == "skylake":
passed.add('test_microarchitecture_detection_skylake_0')
elif label_str[0] == "z15":
passed.add('test_microarchitecture_detection_z15')
elif label_str[0] == "z14":
passed.add('test_microarchitecture_detection_z14')
elif label_str[0] == "z13s":
passed.add('test_microarchitecture_detection_z13s_0')
elif label_str[0] == "z13":
passed.add('test_microarchitecture_detection_z13_0')
else:
skipped.add('test_microarchitecture_not_supported_0')

except ValueError as ve:
print("warning: os version value failed to convert to an integer")
skipped.add('test_microarchitecture_not_supported_0')

rt &= checkResult(result, passed, set(), set(), skipped)
return rt

Expand Down
30 changes: 27 additions & 3 deletions src/org/openj9/envInfo/MachineInfo.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,9 @@ public class MachineInfo {
public static final String[] LINUX_OS_NAME_CMD = new String[] {"bash", "-c", "grep '^NAME' /etc/os-release | awk -F'=' ' gsub(/\"/,\"\") { print $2}'"};
public static final String[] LINUX_OS_VERSION_CMD = new String[] {"bash", "-c", "grep '^VERSION_ID' /etc/os-release | awk -F'=' ' gsub(/\"/,\"\") { print $2}'"};

public static final String[] MICRO_ARCH_CMD = new String[] {"bash", "-c", "cat /proc/cpuinfo | grep 'model name' | uniq"};
// public static final String[] MICRO_ARCH_CMD = new String[] {"bash", "-c", "cat /proc/cpuinfo | grep 'model name' | uniq"};
public static final String[] MICRO_ARCH_CMD = new String[] {"bash", "-c", "cat /proc/cpuinfo | grep -E 'machine|model name' | uniq"};

public static final String[] ULIMIT_CMD = new String[] {"bash", "-c", "ulimit -a"};

public static final String[] INSTALLED_MEM_CMD = new String[] {"bash", "-c", "grep MemTotal /proc/meminfo | awk '{print $2}"};
Expand Down Expand Up @@ -201,10 +203,32 @@ private void getSysInfo() {
putInfo(new Info("sysArch", SYS_ARCH_CMD, ce.execute(SYS_ARCH_CMD), null));
putInfo(new Info("procArch", PROC_ARCH_CMD, ce.execute(PROC_ARCH_CMD), null));
String microArchOutput = ce.execute(MICRO_ARCH_CMD);
// Check for specific machine versions and set the microArch accordingly
if (microArchOutput.toLowerCase().contains("skylake")) {
String microArch = "skylake";
putInfo(new Info("microArch", MICRO_ARCH_CMD, microArch, null));
microArchOutput = "skylake";
} else if (microArchOutput.contains("8562")) {
microArchOutput = "IBM z15 T02";
} else if (microArchOutput.contains("8561")) {
microArchOutput = "IBM z15 T01";
} else if (microArchOutput.contains("3907")) {
microArchOutput = "IBM z14 ZR1";
} else if (microArchOutput.contains("3906")) {
microArchOutput = "IBM z14";
} else if (microArchOutput.contains("2965")) {
microArchOutput = "IBM z13s";
} else if (microArchOutput.contains("2964")) {
microArchOutput= "IBM z13";
}
// Check if the detected microarchitecture is supported
Set<String> supportedMicroArchitectures = new HashSet<>(Arrays.asList("skylake", "z15", "z14", "z13"));

if (supportedMicroArchitectures.stream().anyMatch(microArchOutput.toLowerCase()::contains)) {
putInfo(new Info("microArch", MICRO_ARCH_CMD, microArchOutput, null));
} else {
// The detected microarchitecture is not supported
System.out.println("Detected microarchitecture is not supported: " + microArchOutput);
}

putInfo(new Info("sysOS", SYS_OS_CMD, ce.execute(SYS_OS_CMD), null));
putInfo(new Info("ulimit", ULIMIT_CMD, ce.execute(ULIMIT_CMD), null));
putInfo(new Info("docker", CHECK_DOCKER_CMD, ce.execute(CHECK_DOCKER_CMD), null));
Expand Down

0 comments on commit 8be8ff7

Please sign in to comment.