diff options
| author | Wilson Fung <[email protected]> | 2012-07-26 03:22:53 -0800 |
|---|---|---|
| committer | Andrew Boktor <[email protected]> | 2014-08-14 13:48:52 -0700 |
| commit | 9a0e4e4a776a963c9950dc3dcd0d23ee0739b755 (patch) | |
| tree | 70c6f73230fe8fcfdd0fd2a3a7eb525e1f145b80 | |
| parent | 1c7ed16cc28f1d740ac7abc773eb4016d49fcba4 (diff) | |
Clean up the unordered_map fallback support.
- Now there is only one macro for all use of unordered_map in the code.
- Moving all instances of gcc/cuda version detection into a single file.
- Adding a warning when the fallback is triggered.
[git-p4: depot-paths = "//depot/gpgpu_sim_research/fermi/distribution/": change = 13542]
| -rw-r--r-- | libcuda/Makefile | 3 | ||||
| -rw-r--r-- | libopencl/Makefile | 4 | ||||
| -rw-r--r-- | src/Makefile | 3 | ||||
| -rw-r--r-- | src/abstract_hardware_model.cc | 2 | ||||
| -rw-r--r-- | src/abstract_hardware_model.h | 23 | ||||
| -rw-r--r-- | src/cuda-sim/Makefile | 4 | ||||
| -rw-r--r-- | src/cuda-sim/memory.h | 21 | ||||
| -rw-r--r-- | src/cuda-sim/ptx-stats.cc | 15 | ||||
| -rw-r--r-- | src/gpgpu-sim/Makefile | 3 | ||||
| -rw-r--r-- | src/gpgpu-sim/addrdec.cc | 4 | ||||
| -rw-r--r-- | src/gpgpu-sim/gpu-cache.h | 8 | ||||
| -rw-r--r-- | src/gpgpu-sim/histogram.h | 1 | ||||
| -rw-r--r-- | src/gpgpu-sim/stat-tool.cc | 2 | ||||
| -rw-r--r-- | src/gpgpu-sim/stat-tool.h | 2 | ||||
| -rw-r--r-- | src/tr1_hash_map.h | 25 | ||||
| -rw-r--r-- | version_detection.mk | 38 |
16 files changed, 75 insertions, 83 deletions
diff --git a/libcuda/Makefile b/libcuda/Makefile index e28ae83..399a533 100644 --- a/libcuda/Makefile +++ b/libcuda/Makefile @@ -60,13 +60,12 @@ # Vancouver, BC V6T 1Z4 -CUDART_VERSION:=$(shell $(CUDA_INSTALL_PATH)/bin/nvcc --version | awk '/release/ {print $$5;}' | sed 's/,//' | sed 's/\./ /' | awk '{printf("%02u%02u", 10*int($$1), 10*$$2);}') +include ../version_detection.mk ifeq ($(OPENGL_SUPPORT),1) GL = -DOPENGL_SUPPORT endif -GNUC_CPP0X := $(shell gcc --version | perl -ne 'if (/gcc\s+\(.*\)\s+([0-9.]+)/){ if($$1 >= 4.3) {$$n=1} else {$$n=0;} } END { print $$n; }') ifeq ($(GNUC_CPP0X), 1) CXXFLAGS = -std=c++0x endif diff --git a/libopencl/Makefile b/libopencl/Makefile index ae72115..d597a0d 100644 --- a/libopencl/Makefile +++ b/libopencl/Makefile @@ -60,7 +60,7 @@ # Vancouver, BC V6T 1Z4 -CUDART_VERSION:=$(shell $(CUDA_INSTALL_PATH)/bin/nvcc --version | awk '/release/ {print $$5;}' | sed 's/,//' | sed 's/\./ /' | awk '{printf("%02u%02u", 10*int($$1), 10*$$2);}') +include ../version_detection.mk ifeq ($(OPENGL_SUPPORT),1) GL = -DOPENGL_SUPPORT @@ -74,7 +74,7 @@ CCFLAGS = -O3 -g -Wall -fPIC $(GL) ifeq ($(DEBUG),1) CCFLAGS = -Wall -g -fPIC $(GL) endif -GNUC_CPP0X := $(shell gcc --version | perl -ne 'if (/gcc\s+\(.*\)\s+([0-9.]+)/){ if($$1 >= 4.3) {$$n=1} else {$$n=0;} } END { print $$n; }') + ifeq ($(GNUC_CPP0X), 1) CCFLAGS += -std=c++0x endif diff --git a/src/Makefile b/src/Makefile index fce0f00..b20186c 100644 --- a/src/Makefile +++ b/src/Makefile @@ -31,12 +31,11 @@ DEBUG?=0 -CUDART_VERSION:=$(shell $(CUDA_INSTALL_PATH)/bin/nvcc --version | awk '/release/ {print $$5;}' | sed 's/,//' | sed 's/\./ /' | awk '{printf("%02u%02u", 10*int($$1), 10*$$2);}') +include ../version_detection.mk CXXFLAGS = -Wall -DDEBUG CXXFLAGS += -DCUDART_VERSION=$(CUDART_VERSION) -GNUC_CPP0X := $(shell gcc --version | perl -ne 'if (/gcc\s+\(.*\)\s+([0-9.]+)/){ if($$1 >= 4.3) {$$n=1} else {$$n=0;} } END { print $$n; }') ifeq ($(GNUC_CPP0X), 1) CXXFLAGS += -std=c++0x endif diff --git a/src/abstract_hardware_model.cc b/src/abstract_hardware_model.cc index 955de64..dd1e755 100644 --- a/src/abstract_hardware_model.cc +++ b/src/abstract_hardware_model.cc @@ -383,7 +383,7 @@ void warp_inst_t::memory_coalescing_arch_13_atomic( bool is_write, mem_access_ty unsigned subwarp_size = m_config->warp_size / warp_parts; for( unsigned subwarp=0; subwarp < warp_parts; subwarp++ ) { - std::map<new_addr_type,std::list<transaction_info>> subwarp_transactions; // each block addr maps to a list of transactions + std::map<new_addr_type,std::list<transaction_info> > subwarp_transactions; // each block addr maps to a list of transactions // step 1: find all transactions generated by this subwarp for( unsigned thread=subwarp*subwarp_size; thread<subwarp_size*(subwarp+1); thread++ ) { diff --git a/src/abstract_hardware_model.h b/src/abstract_hardware_model.h index bb5c490..d9f5885 100644 --- a/src/abstract_hardware_model.h +++ b/src/abstract_hardware_model.h @@ -90,29 +90,6 @@ struct dim3 { }; #endif -#if 0 - -// detect gcc 4.3 and use unordered map (part of c++0x) -// unordered map doesn't play nice with _GLIBCXX_DEBUG, just use a map if its enabled. -#if defined( __GNUC__ ) and not defined( _GLIBCXX_DEBUG ) -#if __GNUC__ >= 4 && __GNUC_MINOR__ >= 3 - #include <unordered_map> - #define my_hash_map std::unordered_map -#else - #include <ext/hash_map> - namespace std { - using namespace __gnu_cxx; - } - #define my_hash_map std::hash_map -#endif -#else - #include <map> - #define my_hash_map std::map - #define USE_MAP -#endif - -#endif - void increment_x_then_y_then_z( dim3 &i, const dim3 &bound); class kernel_info_t { diff --git a/src/cuda-sim/Makefile b/src/cuda-sim/Makefile index a2e8da3..3062d99 100644 --- a/src/cuda-sim/Makefile +++ b/src/cuda-sim/Makefile @@ -38,8 +38,7 @@ ifeq ($(INTEL),1) CC = icc endif -CC_VERSION := $(shell gcc --version | perl -ne '/gcc\s+\(.*\)\s+([0-9.]+)/ and print $$1;') -GNUC_CPP0X := $(shell gcc --version | perl -ne 'if (/gcc\s+\(.*\)\s+([0-9.]+)/){ if($$1 >= 4.3) {$$n=1} else {$$n=0;} } END { print $$n; }') +include ../../version_detection.mk OPT := -O3 -g3 -Wall -Wno-unused-function -Wno-sign-compare ifeq ($(DEBUG),1) @@ -61,7 +60,6 @@ OUTPUT_DIR=../../$(SIM_OBJ_FILES_DIR)/cuda-sim OBJS := $(OUTPUT_DIR)/ptx_parser.o $(OUTPUT_DIR)/ptx_loader.o $(OUTPUT_DIR)/cuda_device_printf.o $(OUTPUT_DIR)/instructions.o $(OUTPUT_DIR)/cuda-sim.o $(OUTPUT_DIR)/ptx_ir.o $(OUTPUT_DIR)/ptx_sim.o $(OUTPUT_DIR)/memory.o $(OUTPUT_DIR)/ptx-stats.o $(OUTPUT_DIR)/decuda_pred_table/decuda_pred_table.o $(OUTPUT_DIR)/ptx.tab.o $(OUTPUT_DIR)/lex.ptx_.o $(OUTPUT_DIR)/ptxinfo.tab.o $(OUTPUT_DIR)/lex.ptxinfo_.o -CUDART_VERSION:=$(shell $(CUDA_INSTALL_PATH)/bin/nvcc --version | awk '/release/ {print $$5;}' | sed 's/,//' | sed 's/\./ /' | awk '{printf("%02u%02u", 10*int($$1), 10*$$2);}') OPT += -DCUDART_VERSION=$(CUDART_VERSION) diff --git a/src/cuda-sim/memory.h b/src/cuda-sim/memory.h index 5ebc0ad..f785b8b 100644 --- a/src/cuda-sim/memory.h +++ b/src/cuda-sim/memory.h @@ -30,23 +30,12 @@ #include "../abstract_hardware_model.h" -#ifdef __GNUC__ -#if __GNUC__ >= 4 && __GNUC_MINOR__ >= 3 - #include <unordered_map> - #define mem_map std::unordered_map - #define MEM_MAP_RESIZE(hash_size) m_data.rehash(hash_size) -#else - #include <ext/hash_map> - namespace std { - using namespace __gnu_cxx; - } - #define mem_map std::hash_map - #define MEM_MAP_RESIZE(hash_size) m_data.resize(hash_size) -#endif -#else - #include <map> - #define mem_map std::map +#include "../tr1_hash_map.h" +#define mem_map tr1_hash_map +#if tr1_hash_map_ismap == 1 #define MEM_MAP_RESIZE(hash_size) +#else + #define MEM_MAP_RESIZE(hash_size) (m_data.rehash(hash_size)) #endif #include <assert.h> diff --git a/src/cuda-sim/ptx-stats.cc b/src/cuda-sim/ptx-stats.cc index 3578be9..0a9f08d 100644 --- a/src/cuda-sim/ptx-stats.cc +++ b/src/cuda-sim/ptx-stats.cc @@ -80,14 +80,6 @@ public: unsigned line; }; -struct hash_ptx_file_line -{ - std::size_t operator()(const ptx_file_line & pfline) const { - std::hash<unsigned> hash_line; - return hash_line(pfline.line); - } -}; - // holds all statistics collected for a singe PTX source line class ptx_file_line_stats { @@ -113,6 +105,13 @@ public: #if (tr1_hash_map_ismap == 1) typedef tr1_hash_map<ptx_file_line, ptx_file_line_stats> ptx_file_line_stats_map_t; #else +struct hash_ptx_file_line +{ + std::size_t operator()(const ptx_file_line & pfline) const { + std::hash<unsigned> hash_line; + return hash_line(pfline.line); + } +}; typedef tr1_hash_map<ptx_file_line, ptx_file_line_stats, hash_ptx_file_line> ptx_file_line_stats_map_t; #endif diff --git a/src/gpgpu-sim/Makefile b/src/gpgpu-sim/Makefile index 4f636fb..fdb4503 100644 --- a/src/gpgpu-sim/Makefile +++ b/src/gpgpu-sim/Makefile @@ -38,7 +38,8 @@ else CXXFLAGS_L2CACHE = -Wall endif -GNUC_CPP0X := $(shell gcc --version | perl -ne 'if (/gcc\s+\(.*\)\s+([0-9.]+)/){ if($$1 >= 4.3) {$$n=1} else {$$n=0;} } END { print $$n; }') +include ../../version_detection.mk + ifeq ($(GNUC_CPP0X), 1) CXXFLAGS += -std=c++0x CXXFLAGS_L2CACHE += -std=c++0x diff --git a/src/gpgpu-sim/addrdec.cc b/src/gpgpu-sim/addrdec.cc index 868696d..9b2f339 100644 --- a/src/gpgpu-sim/addrdec.cc +++ b/src/gpgpu-sim/addrdec.cc @@ -331,7 +331,11 @@ void linear_to_raw_address_translation::sweep_test() const { new_addr_type sweep_range = 16 * 1024 * 1024; +#if tr1_hash_map_ismap == 1 + typedef tr1_hash_map<addrdec_t, new_addr_type> history_map_t; +#else typedef tr1_hash_map<addrdec_t, new_addr_type, hash_addrdec_t> history_map_t; +#endif history_map_t history_map; for (new_addr_type raw_addr = 4; raw_addr < sweep_range; raw_addr += 4) { diff --git a/src/gpgpu-sim/gpu-cache.h b/src/gpgpu-sim/gpu-cache.h index ecb1059..3f67ffe 100644 --- a/src/gpgpu-sim/gpu-cache.h +++ b/src/gpgpu-sim/gpu-cache.h @@ -275,9 +275,9 @@ class mshr_table { public: mshr_table( unsigned num_entries, unsigned max_merged ) : m_num_entries(num_entries), - m_max_merged(max_merged), -#ifndef USE_MAP - m_data(2*num_entries) + m_max_merged(max_merged) +#if (tr1_hash_map_ismap == 0) + ,m_data(2*num_entries) #endif { } @@ -377,7 +377,7 @@ private: bool m_has_atomic; mshr_entry() : m_has_atomic(false) { } }; - typedef my_hash_map<new_addr_type,mshr_entry> table; + typedef tr1_hash_map<new_addr_type,mshr_entry> table; table m_data; // it may take several cycles to process the merged requests diff --git a/src/gpgpu-sim/histogram.h b/src/gpgpu-sim/histogram.h index a38a0aa..e8fd375 100644 --- a/src/gpgpu-sim/histogram.h +++ b/src/gpgpu-sim/histogram.h @@ -30,6 +30,7 @@ #ifdef __cplusplus +#include <stdio.h> #include <string> class binned_histogram { diff --git a/src/gpgpu-sim/stat-tool.cc b/src/gpgpu-sim/stat-tool.cc index 94998f2..6a4c75b 100644 --- a/src/gpgpu-sim/stat-tool.cc +++ b/src/gpgpu-sim/stat-tool.cc @@ -479,7 +479,7 @@ void shader_CTA_count_visualizer_gzprint( gzFile fout ) thread_insn_span::thread_insn_span(unsigned long long cycle) : m_cycle(cycle), -#ifdef USE_MAP +#if (tr1_hash_map_ismap == 1) m_insn_span_count() #else m_insn_span_count(32*1024) diff --git a/src/gpgpu-sim/stat-tool.h b/src/gpgpu-sim/stat-tool.h index 062d4bd..5646f01 100644 --- a/src/gpgpu-sim/stat-tool.h +++ b/src/gpgpu-sim/stat-tool.h @@ -95,7 +95,7 @@ public: void print_sparse_histo(gzFile fout) const; private: - typedef my_hash_map<address_type, int> span_count_map; + typedef tr1_hash_map<address_type, int> span_count_map; unsigned long long m_cycle; span_count_map m_insn_span_count; }; diff --git a/src/tr1_hash_map.h b/src/tr1_hash_map.h index 611d4d4..a2d3334 100644 --- a/src/tr1_hash_map.h +++ b/src/tr1_hash_map.h @@ -29,7 +29,9 @@ // detection and fallback for unordered_map in C++0x #ifdef __cplusplus - #ifdef __GNUC__ + // detect GCC 4.3 or later and use unordered map (part of C++0x) + // unordered map doesn't play nice with _GLIBCXX_DEBUG, just use a map if its enabled. + #if defined( __GNUC__ ) and not defined( _GLIBCXX_DEBUG ) #if __GNUC__ >= 4 && __GNUC_MINOR__ >= 3 #include <unordered_map> #define tr1_hash_map std::unordered_map @@ -45,23 +47,8 @@ #define tr1_hash_map_ismap 1 #endif - // detect gcc 4.3 and use unordered map (part of c++0x) - // unordered map doesn't play nice with _GLIBCXX_DEBUG, just use a map if its enabled. - #if defined( __GNUC__ ) and not defined( _GLIBCXX_DEBUG ) - #if __GNUC__ >= 4 && __GNUC_MINOR__ >= 3 - #include <unordered_map> - #define my_hash_map std::unordered_map - #else - #include <ext/hash_map> - namespace std { - using namespace __gnu_cxx; - } - #define my_hash_map std::hash_map - #endif - #else - #include <map> - #define my_hash_map std::map - #define USE_MAP - #endif + #if tr1_hash_map_ismap == 1 + #warning "Pre-C++11 GCC version detected. Downgrading all use of <unordered_map> to <map>. Please upgrade to GCC 4.3 or later for faster simulation." + #endif #endif diff --git a/version_detection.mk b/version_detection.mk new file mode 100644 index 0000000..d73a05e --- /dev/null +++ b/version_detection.mk @@ -0,0 +1,38 @@ +# Copyright (c) 2009-2011, Tor M. Aamodt +# Wilson W.L. Fung, Ali Bakhoda +# The University of British Columbia +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# +# Redistributions of source code must retain the above copyright notice, this +# list of conditions and the following disclaimer. +# Redistributions in binary form must reproduce the above copyright notice, this +# list of conditions and the following disclaimer in the documentation and/or +# other materials provided with the distribution. +# Neither the name of The University of British Columbia nor the names of its +# contributors may be used to endorse or promote products derived from this +# software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + +# Detect CUDA Runtime Version +CUDART_VERSION:=$(shell $(CUDA_INSTALL_PATH)/bin/nvcc --version | awk '/release/ {print $$5;}' | sed 's/,//' | sed 's/\./ /' | awk '{printf("%02u%02u", 10*int($$1), 10*$$2);}') + +# Detect GCC Version +CC_VERSION := $(shell gcc --version | perl -ne '/gcc\s+\(.*\)\s+([0-9.]+)/ and print $$1;') + +# Detect Support for C++11 (C++0x) from GCC Version +GNUC_CPP0X := $(shell gcc --version | perl -ne 'if (/gcc\s+\(.*\)\s+([0-9.]+)/){ if($$1 >= 4.3) {$$n=1} else {$$n=0;} } END { print $$n; }') + |
