Gabe Black has uploaded this change for review. ( https://gem5-review.googlesource.com/c/public/gem5/+/40873 )

Change subject: scons,gpu: Use a config header for the BUILD_GPU setting.
......................................................................

scons,gpu: Use a config header for the BUILD_GPU setting.

The BUILD_GPU setting was being set by adding a -D to the command line
at the top level SConstruct. Instead, add BUILD_GPU to export_vars so
that it ends up in a config/build_gpu.hh header. Also switch it from the
fairly dangerous #ifdef style to the safer #if.

Change-Id: Ic93d37c9d7671023a6978842dbb2750c3e92f8d8
---
M SConstruct
M src/gpu-compute/SConsopts
M src/mem/ruby/profiler/Profiler.cc
3 files changed, 12 insertions(+), 168 deletions(-)



diff --git a/SConstruct b/SConstruct
index 74ae060..41ea6d7 100755
--- a/SConstruct
+++ b/SConstruct
@@ -453,37 +453,7 @@
     main.Append(CCFLAGS=["-Wno-uninitialized"])


-have_pkg_config = main.Detect('pkg-config')
-main['HAVE_PKG_CONFIG'] = have_pkg_config
-
-# Check for the protobuf compiler
-main['HAVE_PROTOC'] = False
-protoc_version = None
-try:
-    protoc_version = readCommand([main['PROTOC'], '--version']).split()
-except Exception as e:
-    warning('While checking protoc version:', str(e))
-
-# Based on the availability of the compress stream wrappers, require 2.1.0.
-min_protoc_version = '2.1.0'
-
-# First two words should be "libprotoc x.y.z"
-if len(protoc_version) < 2 or protoc_version[0] != 'libprotoc':
-    warning('Protocol buffer compiler (protoc) not found.\n'
-            'Please install protobuf-compiler for tracing support.')
-elif compareVersions(protoc_version[1], min_protoc_version) < 0:
-    warning('protoc version', min_protoc_version, 'or newer required.\n'
-            'Installed version:', protoc_version[1])
-else:
-    # Attempt to determine the appropriate include path and
-    # library path using pkg-config, that means we also need to
-    # check for pkg-config. Note that it is possible to use
-    # protobuf without the involvement of pkg-config. Later on we
-    # check go a library config check and at that point the test
-    # will fail if libprotobuf cannot be found.
-    if have_pkg_config:
-        conf.CheckPkgConfig('protobuf', '--cflags', '--libs-only-L')
-    main['HAVE_PROTOC'] = True
+main['HAVE_PKG_CONFIG'] = main.Detect('pkg-config')


 # We should compile a 64 bit binary on Mac OS X/Darwin
@@ -604,34 +574,6 @@
           'and/or zlib.h header file.\n'
           'Please install zlib and try again.')

-# If we have the protobuf compiler, also make sure we have the
-# development libraries. If the check passes, libprotobuf will be
-# automatically added to the LIBS environment variable. After
-# this, we can use the HAVE_PROTOBUF flag to determine if we have
-# got both protoc and libprotobuf available.
-main['HAVE_PROTOBUF'] = main['HAVE_PROTOC'] and \
-    conf.CheckLibWithHeader('protobuf', 'google/protobuf/message.h',
-                            'C++', 'GOOGLE_PROTOBUF_VERIFY_VERSION;')
-
-# Valgrind gets much less confused if you tell it when you're using
-# alternative stacks.
-main['HAVE_VALGRIND'] = conf.CheckCHeader('valgrind/valgrind.h')
-
-# If we have the compiler but not the library, print another warning.
-if main['HAVE_PROTOC'] and not main['HAVE_PROTOBUF']:
-    warning('Did not find protocol buffer library and/or headers.\n'
-            'Please install libprotobuf-dev for tracing support.')
-
-# Check for librt.
-have_posix_clock = \
-    conf.CheckLibWithHeader([None, 'rt'], 'time.h', 'C',
-                            'clock_nanosleep(0,0,NULL,NULL);')
-if not have_posix_clock:
-    warning("Can't find library for POSIX clocks.")
-
-have_posix_timers = \
-    conf.CheckLibWithHeader([None, 'rt'], [ 'time.h', 'signal.h' ], 'C',
-                            'timer_create(CLOCK_MONOTONIC, NULL, NULL);')

 if not GetOption('without_tcmalloc'):
     if conf.CheckLib('tcmalloc'):
@@ -644,63 +586,6 @@
                 "on Ubuntu or RedHat).")


-if conf.CheckLibWithHeader([None, 'execinfo'], 'execinfo.h', 'C',
-        'char temp; backtrace_symbols_fd((void *)&temp, 0, 0);'):
-    main['BACKTRACE_IMPL'] = 'glibc'
-else:
-    main['BACKTRACE_IMPL'] = 'none'
-    warning("No suitable back trace implementation found.")
-
-# Check for <fenv.h> (C99 FP environment control)
-have_fenv = conf.CheckHeader('fenv.h', '<>')
-if not have_fenv:
-    warning("Header file <fenv.h> not found.\n"
-            "This host has no IEEE FP rounding mode control.")
-
-# Check for <png.h> (libpng library needed if wanting to dump
-# frame buffer image in png format)
-have_png = conf.CheckHeader('png.h', '<>')
-if not have_png:
-    warning("Header file <png.h> not found.\n"
-            "This host has no libpng library.\n"
-            "Disabling support for PNG framebuffers.")
-
-# Check if we should enable KVM-based hardware virtualization. The API
-# we rely on exists since version 2.6.36 of the kernel, but somehow
-# the KVM_API_VERSION does not reflect the change. We test for one of
-# the types as a fall back.
-have_kvm = conf.CheckHeader('linux/kvm.h', '<>')
-if not have_kvm:
-    print("Info: Compatible header file <linux/kvm.h> not found, "
-          "disabling KVM support.")
-
-# Determine what ISA KVM can support on this host.
-kvm_isa = None
-host_isa = None
-try:
-    import platform
-    host_isa = platform.machine()
-except:
-    pass
-
-if not host_isa:
-    warning("Failed to determine host ISA.")
-elif not have_posix_timers:
- warning("Cannot enable KVM, host seems to lack support for POSIX timers")
-elif host_isa in ('armv71', 'aarch64'):
-    kvm_isa = 'arm'
-elif host_isa == 'x86_64':
- if conf.CheckTypeSize('struct kvm_xsave', '#include <linux/kvm.h>') != 0:
-        kvm_isa = 'x86'
-    else:
-        warning("KVM on x86 requires xsave support in kernel headers.")
-
-
-# Check if the exclude_host attribute is available. We want this to
-# get accurate instruction counts in KVM.
-main['HAVE_PERF_ATTR_EXCLUDE_HOST'] = conf.CheckMember(
-    'linux/perf_event.h', 'struct perf_event_attr', 'exclude_host')
-
 ######################################################################
 #
 # Finish the configuration
@@ -724,7 +609,8 @@
 sticky_vars = Variables(args=ARGUMENTS)
 Export('sticky_vars')

-# Sticky variables that should be exported
+# Sticky variables that should be exported to #defines in config/*.hh
+# (see src/SConscript).
 export_vars = []
 Export('export_vars')

@@ -747,22 +633,13 @@
     cb()

 sticky_vars.AddVariables(
- BoolVariable('EFENCE', 'Link with Electric Fence malloc debugger', False),
+    BoolVariable('USE_EFENCE', 'Link with Electric Fence malloc debugger',
+                  False),
     BoolVariable('USE_SSE2',
                  'Compile for SSE2 (-msse2) to get IEEE FP on x86 hosts',
                  False),
-    BoolVariable('USE_POSIX_CLOCK', 'Use POSIX Clocks', have_posix_clock),
-    BoolVariable('USE_FENV', 'Use <fenv.h> IEEE mode control', have_fenv),
-    BoolVariable('USE_PNG',  'Enable support for PNG images', have_png),
-    BoolVariable('USE_KVM', 'Enable hardware virtualized (KVM) CPU models',
-                 have_kvm),
     )

-# These variables get exported to #defines in config/*.hh (see src/SConscript).
-export_vars += ['USE_FENV', 'USE_POSIX_CLOCK', 'USE_KVM',
-                'HAVE_PROTOBUF', 'HAVE_VALGRIND',
-                'HAVE_PERF_ATTR_EXCLUDE_HOST', 'USE_PNG']
-
 ###################################################
 #
 # Define a SCons builder for configuration flag headers.
@@ -942,45 +819,9 @@
          append=True)

     # Process variable settings.
-
-    if not have_fenv and env['USE_FENV']:
-        warning("<fenv.h> not available; forcing USE_FENV to False in",
-                variant_dir + ".")
-        env['USE_FENV'] = False
-
-    if not env['USE_FENV']:
-        warning("No IEEE FP rounding mode control in", variant_dir + ".\n"
-                "FP results may deviate slightly from other platforms.")
-
-    if not have_png and env['USE_PNG']:
-        warning("<png.h> not available; forcing USE_PNG to False in",
-                variant_dir + ".")
-        env['USE_PNG'] = False
-
-    if env['USE_PNG']:
-        env.Append(LIBS=['png'])
-
-    if env['EFENCE']:
+    if env['USE_EFENCE']:
         env.Append(LIBS=['efence'])

-    if env['USE_KVM']:
-        if not have_kvm:
-            warning("Can not enable KVM, host seems to lack KVM support")
-            env['USE_KVM'] = False
-        elif kvm_isa != env['TARGET_ISA']:
-            print("Info: KVM for %s not supported on %s host." %
-                  (env['TARGET_ISA'], kvm_isa))
-            env['USE_KVM'] = False
-
-    if env['BUILD_GPU']:
-        env.Append(CPPDEFINES=['BUILD_GPU'])
-
-    # Warn about missing optional functionality
-    if env['USE_KVM']:
-        if not main['HAVE_PERF_ATTR_EXCLUDE_HOST']:
-            warning("perf_event headers lack support for the exclude_host "
- "attribute. KVM instruction counts will be inaccurate.")
-
     # Save sticky variable settings back to current variables file
     sticky_vars.Save(current_vars_file, env)

diff --git a/src/gpu-compute/SConsopts b/src/gpu-compute/SConsopts
index 251ac5d..1737c13 100644
--- a/src/gpu-compute/SConsopts
+++ b/src/gpu-compute/SConsopts
@@ -27,3 +27,5 @@

 sticky_vars.Add(BoolVariable('BUILD_GPU', 'Build the compute-GPU model',
                              False))
+
+export_vars.append('BUILD_GPU')
diff --git a/src/mem/ruby/profiler/Profiler.cc b/src/mem/ruby/profiler/Profiler.cc
index 312cf1d..7e66311 100644
--- a/src/mem/ruby/profiler/Profiler.cc
+++ b/src/mem/ruby/profiler/Profiler.cc
@@ -52,6 +52,7 @@

 #include "base/stl_helpers.hh"
 #include "base/str.hh"
+#include "config/build_gpu.hh"
 #include "mem/ruby/network/Network.hh"
 #include "mem/ruby/profiler/AddressProfiler.hh"
 #include "mem/ruby/protocol/MachineType.hh"
@@ -70,7 +71,7 @@
  * here, but until then these ifdefs will
  * serve.
  */
-#ifdef BUILD_GPU
+#if BUILD_GPU
 #include "mem/ruby/system/GPUCoalescer.hh"

 #endif
@@ -391,7 +392,7 @@
                 rubyProfilerStats.
                     m_outstandReqHistSeqr.add(seq->getOutstandReqHist());
             }
-#ifdef BUILD_GPU
+#if BUILD_GPU
             GPUCoalescer *coal = ctr->getGPUCoalescer();
             if (coal != NULL) {
                 rubyProfilerStats.
@@ -488,7 +489,7 @@
                     }
                 }
             }
-#ifdef BUILD_GPU
+#if BUILD_GPU
             GPUCoalescer *coal = ctr->getGPUCoalescer();
             if (coal != NULL) {
                 // add all the latencies

--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/40873
To unsubscribe, or for help writing mail filters, visit https://gem5-review.googlesource.com/settings

Gerrit-Project: public/gem5
Gerrit-Branch: develop
Gerrit-Change-Id: Ic93d37c9d7671023a6978842dbb2750c3e92f8d8
Gerrit-Change-Number: 40873
Gerrit-PatchSet: 1
Gerrit-Owner: Gabe Black <[email protected]>
Gerrit-MessageType: newchange
_______________________________________________
gem5-dev mailing list -- [email protected]
To unsubscribe send an email to [email protected]
%(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s

Reply via email to