From 9a0e4e4a776a963c9950dc3dcd0d23ee0739b755 Mon Sep 17 00:00:00 2001 From: Wilson Fung Date: Thu, 26 Jul 2012 03:22:53 -0800 Subject: 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] --- src/cuda-sim/Makefile | 4 +--- src/cuda-sim/memory.h | 21 +++++---------------- src/cuda-sim/ptx-stats.cc | 15 +++++++-------- 3 files changed, 13 insertions(+), 27 deletions(-) (limited to 'src/cuda-sim') 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 - #define mem_map std::unordered_map - #define MEM_MAP_RESIZE(hash_size) m_data.rehash(hash_size) -#else - #include - 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 - #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 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 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_stats_map_t; #else +struct hash_ptx_file_line +{ + std::size_t operator()(const ptx_file_line & pfline) const { + std::hash hash_line; + return hash_line(pfline.line); + } +}; typedef tr1_hash_map ptx_file_line_stats_map_t; #endif -- cgit v1.3