src/os_cpu/solaris_sparc/vm/vm_version_solaris_sparc.cpp
Index
Unified diffs
Context diffs
Sdiffs
Patch
New
Old
Previous File
Next File
hs-comp Cdiff src/os_cpu/solaris_sparc/vm/vm_version_solaris_sparc.cpp
src/os_cpu/solaris_sparc/vm/vm_version_solaris_sparc.cpp
Print this page
*** 26,39 ****
#include "memory/allocation.hpp"
#include "memory/allocation.inline.hpp"
#include "runtime/os.hpp"
#include "vm_version_sparc.hpp"
! # include <sys/auxv.h>
! # include <sys/auxv_SPARC.h>
! # include <sys/systeminfo.h>
! # include <kstat.h>
// We need to keep these here as long as we have to build on Solaris
// versions before 10.
#ifndef SI_ARCHITECTURE_32
#define SI_ARCHITECTURE_32 516 /* basic 32-bit SI_ARCHITECTURE */
--- 26,147 ----
#include "memory/allocation.hpp"
#include "memory/allocation.inline.hpp"
#include "runtime/os.hpp"
#include "vm_version_sparc.hpp"
! #include <sys/auxv.h>
! #include <sys/auxv_SPARC.h>
! #include <sys/systeminfo.h>
! #include <kstat.h>
! #include <picl.h>
!
! extern "C" static int PICL_get_cache_line_sizes_helper(picl_nodehdl_t nodeh, void *result);
!
!
! class PICL {
! // Get a value of the integer property. The value in the tree can be either 32 or 64 bit
! // depending on the platform. The result is converted to int.
! static int get_int_property(picl_nodehdl_t nodeh, const char* name, int* result) {
! picl_propinfo_t pinfo;
! picl_prophdl_t proph;
! if (picl_get_prop_by_name(nodeh, name, &proph) != PICL_SUCCESS ||
! picl_get_propinfo(proph, &pinfo) != PICL_SUCCESS) {
! return PICL_FAILURE;
! }
!
! if (pinfo.type != PICL_PTYPE_INT && pinfo.type != PICL_PTYPE_UNSIGNED_INT) {
! assert(false, "Invalid property type");
! return PICL_FAILURE;
! }
! if (pinfo.size == sizeof(int64_t)) {
! int64_t val;
! if (picl_get_propval(proph, &val, sizeof(int64_t)) != PICL_SUCCESS) {
! return PICL_FAILURE;
! }
! *result = static_cast<int>(val);
! } else if (pinfo.size == sizeof(int32_t)) {
! int32_t val;
! if (picl_get_propval(proph, &val, sizeof(int32_t)) != PICL_SUCCESS) {
! return PICL_FAILURE;
! }
! *result = static_cast<int>(val);
! } else {
! assert(false, "Unexpected integer property size");
! return PICL_FAILURE;
! }
! return PICL_SUCCESS;
! }
!
!
! static const int PROP_INCONSISTENT = -1;
! static const int PROP_MISSING = -2;
! // For every visited node make sure the specified property exists and has the same value
! static int get_int_property_and_ensure_consistency(picl_nodehdl_t nodeh, const char* name, void *result) {
! int *prev = static_cast<int*>(result);
! int curr;
! if (*prev >= 0) { // are still interested in walking?
! if (get_int_property(nodeh, name, &curr) == PICL_SUCCESS) {
! if (*prev == 0) { // first
! *prev = curr;
! return PICL_WALK_CONTINUE;
! } else if (curr == *prev) { // others
! return PICL_WALK_CONTINUE;
! } else {
! *prev = PROP_INCONSISTENT;
! }
! } else {
! // missing property?
! *prev = PROP_MISSING;
! }
! }
! return PICL_WALK_TERMINATE;
! }
!
! struct CacheLineSizes {
! int _L1_data;
! int _L2;
! CacheLineSizes() : _L1_data(0), _L2(0) {}
! } _cache_line_sizes;
!
! public:
! static int get_cache_line_sizes(picl_nodehdl_t nodeh, void *result)
! {
! CacheLineSizes *sizes = static_cast<CacheLineSizes*>(result);
! int r1 = get_int_property_and_ensure_consistency(nodeh, "l2-cache-line-size", &(sizes->_L2));
! int r2 = get_int_property_and_ensure_consistency(nodeh, "l1-dcache-line-size", &(sizes->_L1_data));
! if (r1 == PICL_WALK_TERMINATE && r2 == PICL_WALK_TERMINATE) {
! return PICL_WALK_TERMINATE;
! }
! return PICL_WALK_CONTINUE;
! }
!
! PICL() {
! if (picl_initialize() == PICL_SUCCESS) {
! picl_nodehdl_t rooth;
! if (picl_get_root(&rooth) == PICL_SUCCESS) {
! // Visit all CPUs
! CacheLineSizes cpu_cache_sizes, core_cache_sizes;
! picl_walk_tree_by_class(rooth, "cpu", &cpu_cache_sizes, PICL_get_cache_line_sizes_helper);
! picl_walk_tree_by_class(rooth, "core", &core_cache_sizes, PICL_get_cache_line_sizes_helper);
! if (cpu_cache_sizes._L1_data != PROP_INCONSISTENT && core_cache_sizes._L1_data != PROP_INCONSISTENT) {
! _cache_line_sizes._L1_data = MAX2(cpu_cache_sizes._L1_data, core_cache_sizes._L1_data);
! }
! if (cpu_cache_sizes._L2 != PROP_INCONSISTENT && core_cache_sizes._L2 != PROP_INCONSISTENT) {
! _cache_line_sizes._L2 = MAX2(cpu_cache_sizes._L2, core_cache_sizes._L2);
! }
! }
! picl_shutdown();
! }
! }
!
! unsigned int L1_data_cache_line_size() const { return _cache_line_sizes._L1_data; }
! unsigned int L2_cache_line_size() const { return _cache_line_sizes._L2; }
! };
!
! extern "C" static int PICL_get_cache_line_sizes_helper(picl_nodehdl_t nodeh, void *result) {
! return PICL::get_cache_line_sizes(nodeh, result);
! }
// We need to keep these here as long as we have to build on Solaris
// versions before 10.
#ifndef SI_ARCHITECTURE_32
#define SI_ARCHITECTURE_32 516 /* basic 32-bit SI_ARCHITECTURE */
*** 209,215 ****
--- 317,328 ----
assert(strcmp(implementation, "UNKNOWN") != 0,
"unknown cpu info (changed kstat interface?)");
kstat_close(kc);
}
+ // Figure out cache line sizes using PICL
+ PICL picl;
+ _L1_data_cache_line_size = picl.L1_data_cache_line_size();
+ _L2_cache_line_size = picl.L2_cache_line_size();
+
return features;
}
src/os_cpu/solaris_sparc/vm/vm_version_solaris_sparc.cpp
Index
Unified diffs
Context diffs
Sdiffs
Patch
New
Old
Previous File
Next File