8238596: AVX enabled by default for Skylake even when unsupported

Only default to UseAVX=2 when support is detected

Reviewed-by: shade, vlivanov
This commit is contained in:
David Buck 2020-02-10 03:35:50 -05:00
parent 04c1e2e931
commit 6aeb78d3df
2 changed files with 12 additions and 6 deletions

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 1997, 2019, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 1997, 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -672,11 +672,14 @@ void VM_Version::get_processor_features() {
} }
} }
if (FLAG_IS_DEFAULT(UseAVX)) { if (FLAG_IS_DEFAULT(UseAVX)) {
FLAG_SET_DEFAULT(UseAVX, use_avx_limit); // Don't use AVX-512 on older Skylakes unless explicitly requested.
if (is_intel_family_core() && _model == CPU_MODEL_SKYLAKE && _stepping < 5) { if (use_avx_limit > 2 && is_intel_skylake() && _stepping < 5) {
FLAG_SET_DEFAULT(UseAVX, 2); //Set UseAVX=2 for Skylake FLAG_SET_DEFAULT(UseAVX, 2);
} else {
FLAG_SET_DEFAULT(UseAVX, use_avx_limit);
} }
} else if (UseAVX > use_avx_limit) { }
if (UseAVX > use_avx_limit) {
warning("UseAVX=%d is not supported on this CPU, setting it to UseAVX=%d", (int) UseAVX, use_avx_limit); warning("UseAVX=%d is not supported on this CPU, setting it to UseAVX=%d", (int) UseAVX, use_avx_limit);
FLAG_SET_DEFAULT(UseAVX, use_avx_limit); FLAG_SET_DEFAULT(UseAVX, use_avx_limit);
} else if (UseAVX < 0) { } else if (UseAVX < 0) {

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 1997, 2019, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 1997, 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -868,6 +868,9 @@ public:
static bool is_intel_family_core() { return is_intel() && static bool is_intel_family_core() { return is_intel() &&
extended_cpu_family() == CPU_FAMILY_INTEL_CORE; } extended_cpu_family() == CPU_FAMILY_INTEL_CORE; }
static bool is_intel_skylake() { return is_intel_family_core() &&
extended_cpu_model() == CPU_MODEL_SKYLAKE; }
static bool is_intel_tsc_synched_at_init() { static bool is_intel_tsc_synched_at_init() {
if (is_intel_family_core()) { if (is_intel_family_core()) {
uint32_t ext_model = extended_cpu_model(); uint32_t ext_model = extended_cpu_model();