diff options
| author | Tor Aamodt <[email protected]> | 2010-10-01 08:55:28 -0800 |
|---|---|---|
| committer | Tor Aamodt <[email protected]> | 2010-10-01 08:55:28 -0800 |
| commit | 11b308e7363e937966b035b4891db32b4eece3bf (patch) | |
| tree | 50ca4c9ad6f163ac4acb2bf505e64dfebed66947 /common | |
| parent | bb820c116764d7a1b8e071137d32b74e7f34dd2f (diff) | |
integrating recent changes from fermi-test into fermi
(i'll use "fermi" for more disruptive changes to the pipeline model such
as updating the MSHRs and getting rid of the warp tracker, ripping out DWF, etc...)
[git-p4: depot-paths = "//depot/gpgpu_sim_research/fermi/distribution/": change = 7805]
Diffstat (limited to 'common')
| -rw-r--r-- | common/common.mk | 481 |
1 files changed, 362 insertions, 119 deletions
diff --git a/common/common.mk b/common/common.mk index 9ccebfb..163f535 100644 --- a/common/common.mk +++ b/common/common.mk @@ -1,136 +1,379 @@ -# Copyright (c) 2009 by Tor M. Aamodt, Wilson W. L. Fung, Ali Bakhoda, -# George L. Yuan, Jimmy Kwa and the -# University of British Columbia -# Vancouver, BC V6T 1Z4 -# All Rights Reserved. -# -# THIS IS A LEGAL DOCUMENT BY DOWNLOADING GPGPU-SIM, YOU ARE AGREEING TO THESE -# TERMS AND CONDITIONS. -# -# 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 OWNERS 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. -# -# NOTE: The files libcuda/cuda_runtime_api.c and src/cuda-sim/cuda-math.h -# are derived from the CUDA Toolset available from http://www.nvidia.com/cuda -# (property of NVIDIA). The files benchmarks/BlackScholes/* and -# benchmarks/template/* are derived from the CUDA SDK available from -# http://www.nvidia.com/cuda (also property of NVIDIA). The files -# src/gpgpusim_entrypoint.c and src/simplesim-3.0/* are derived from the -# SimpleScalar Toolset available from http://www.simplescalar.com/ -# (property of SimpleScalar LLC) and the files src/intersim/* are derived -# from Booksim (Simulator provided with the textbook "Principles and -# Practices of Interconnection Networks" available from -# http://cva.stanford.edu/books/ppin/). As such, those files are bound by -# the corresponding legal terms and conditions set forth separately (original -# copyright notices are left in files from these sources and where we have -# modified a file our copyright notice appears before the original copyright -# notice). -# -# Using this version of GPGPU-Sim requires a complete installation of CUDA -# version 1.1, which is distributed seperately by NVIDIA under separate terms -# and conditions. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are met: -# -# 1. Redistributions of source code must retain the above copyright notice, -# this list of conditions and the following disclaimer. -# -# 2. 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. -# -# 3. 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. -# -# 4. This version of GPGPU-SIM is distributed freely for non-commercial use only. -# -# 5. No nonprofit user may place any restrictions on the use of this software, -# including as modified by the user, by any other authorized user. -# -# 6. GPGPU-SIM was developed primarily by Tor M. Aamodt, Wilson W. L. Fung, -# Ali Bakhoda, George L. Yuan, at the University of British Columbia, -# Vancouver, BC V6T 1Z4 +################################################################################ +# +# Copyright 1993-2006 NVIDIA Corporation. All rights reserved. +# +# NOTICE TO USER: +# +# This source code is subject to NVIDIA ownership rights under U.S. and +# international Copyright laws. +# +# NVIDIA MAKES NO REPRESENTATION ABOUT THE SUITABILITY OF THIS SOURCE +# CODE FOR ANY PURPOSE. IT IS PROVIDED "AS IS" WITHOUT EXPRESS OR +# IMPLIED WARRANTY OF ANY KIND. NVIDIA DISCLAIMS ALL WARRANTIES WITH +# REGARD TO THIS SOURCE CODE, INCLUDING ALL IMPLIED WARRANTIES OF +# MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE. +# IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL, +# OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS +# OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE +# OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE +# OR PERFORMANCE OF THIS SOURCE CODE. +# +# U.S. Government End Users. This source code is a "commercial item" as +# that term is defined at 48 C.F.R. 2.101 (OCT 1995), consisting of +# "commercial computer software" and "commercial computer software +# documentation" as such terms are used in 48 C.F.R. 12.212 (SEPT 1995) +# and is provided to the U.S. Government only as a commercial end item. +# Consistent with 48 C.F.R.12.212 and 48 C.F.R. 227.7202-1 through +# 227.7202-4 (JUNE 1995), all U.S. Government End Users acquire the +# source code with only those rights set forth herein. +# +################################################################################ +# +# Common build script +# +################################################################################ -CPP = g++ $(SNOW) -CC = gcc $(SNOW) +.SUFFIXES : .cu .cu_dbg.o .c_dbg.o .cpp_dbg.o .cu_rel.o .c_rel.o .cpp_rel.o .cubin .ptx -NVCC_VERSION:=$(shell nvcc --version | awk '/release/ {print $$5;}' | sed 's/,//') -INCFLAGEXTRA ?= -CFLAGS ?= -CCFLAGS ?= -CUFLAGS ?= -NEWLIBDIR ?= -LIB ?= -SRCDIR ?= -ROOTDIR ?= -ROOTBINDIR ?= bin -BINDIR ?= $(ROOTBINDIR) +# Add new SM Versions here as devices with new Compute Capability are released +SM_VERSIONS := sm_10 sm_11 sm_12 sm_13 + +CUDA_INSTALL_PATH ?= /usr/local/cuda + +ifdef cuda-install + CUDA_INSTALL_PATH := $(cuda-install) +endif + +# detect OS +OSUPPER = $(shell uname -s 2>/dev/null | tr [:lower:] [:upper:]) +OSLOWER = $(shell uname -s 2>/dev/null | tr [:upper:] [:lower:]) +# 'linux' is output for Linux system, 'darwin' for OS X +DARWIN = $(strip $(findstring DARWIN, $(OSUPPER))) + +# detect if 32 bit or 64 bit system +HP_64 = $(shell uname -m | grep 64) + +# Basic directory setup for SDK +# (override directories only if they are not already defined) +SRCDIR ?= +ROOTDIR ?= $(NVIDIA_CUDA_SDK_LOCATION)/C/src +ROOTBINDIR ?= $(shell pwd)/../bin +BINDIR ?= $(ROOTBINDIR)/$(OSLOWER) ROOTOBJDIR ?= obj -ifneq ($(NVCC_VERSION),2.3) -LIBDIR := "$(NVIDIA_CUDA_SDK_LOCATION)/lib" -COMMONDIR := "$(NVIDIA_CUDA_SDK_LOCATION)/common" -SDKINCDIR := "$(NVIDIA_CUDA_SDK_LOCATION)/common/inc/" +LIBDIR := $(ROOTDIR)/../lib +COMMONDIR := $(ROOTDIR)/../common + +# Compilers +ifeq "$(strip $(HP_64))" "" + NVCC := $(CUDA_INSTALL_PATH)/bin/nvcc else -LIBDIR := "$(NVIDIA_CUDA_SDK_LOCATION)/C/lib" -COMMONDIR := "$(NVIDIA_CUDA_SDK_LOCATION)/C/common" -SDKINCDIR := "$(NVIDIA_CUDA_SDK_LOCATION)/C/common/inc/" + NVCC := $(CUDA_INSTALL_PATH)/bin/nvcc endif -LIB += -lm -lz -ifeq ($(shell uname),Linux) - CUTIL:=cutil - LIB += -lGL -else - CUTIL:=cutil_i386 + +CXX := g++ +CC := gcc +LINK := g++ -fPIC +ifdef NEWCPP + CXX := $(NEWCPP) endif -GPGPUSIM_ROOT ?= ../.. -INTERMED_FILES := *.cpp*.i *.cpp*.ii *.cu.c *.cudafe*.* *.fatbin.c *.cu.cpp *.linkinfo *.cpp_o core +ifdef NEWCC + CC := $(NEWCC) +endif +ifdef NEWLD + LINK := $(NEWLD) +endif + +# Includes +INCLUDES += -I. -I$(CUDA_INSTALL_PATH)/include -I$(COMMONDIR)/inc $(INCFLAGEXTRA) + +# architecture flag for cubin build +CUBIN_ARCH_FLAG := + +# Warning flags +CXXWARN_FLAGS := \ + -W -Wall \ + -Wimplicit \ + -Wswitch \ + -Wformat \ + -Wchar-subscripts \ + -Wparentheses \ + -Wmultichar \ + -Wtrigraphs \ + -Wpointer-arith \ + -Wcast-align \ + -Wreturn-type \ + -Wno-unused-function \ + $(SPACE) -SIM_OBJDIR := -SIM_OBJS += $(patsubst %.cpp,$(SIM_OBJDIR)%.cpp_o,$(CCFILES)) -SIM_OBJS += $(patsubst %.c,$(SIM_OBJDIR)%.c_o,$(CFILES)) -SIM_OBJS += $(patsubst %.cu,$(SIM_OBJDIR)%.cu_o,$(CUFILES)) +CWARN_FLAGS := $(CXXWARN_FLAGS) \ + -Wstrict-prototypes \ + -Wmissing-prototypes \ + -Wmissing-declarations \ + -Wnested-externs \ + -Wmain \ + +# Compiler-specific flags +NVCCFLAGS := +CXXFLAGS := $(CXXWARN_FLAGS) +CFLAGS := $(CWARN_FLAGS) + +# Common flags +COMMONFLAGS += $(INCLUDES) -DUNIX + +# Debug/release configuration +ifeq ($(dbg),1) + COMMONFLAGS += -g + NVCCFLAGS += -D_DEBUG + CXXFLAGS += -D_DEBUG + CFLAGS += -D_DEBUG + BINSUBDIR := debug + LIBSUFFIX := D +else + COMMONFLAGS += -g -O2 + BINSUBDIR := release + LIBSUFFIX := + NVCCFLAGS += --compiler-options -fno-strict-aliasing + CXXFLAGS += -fno-strict-aliasing + CFLAGS += -fno-strict-aliasing +endif -.SUFFIXES: +# append optional arch/SM version flags (such as -arch sm_11) +#NVCCFLAGS += $(SMVERSIONFLAGS) -gpgpu_ptx_sim__$(EXECUTABLE): $(SIM_OBJS) $(GPGPUSIM_ROOT)/src/cuda-sim/libgpgpu_ptx_sim.a $(GPGPUSIM_ROOT)/src/libgpgpusim.a $(GPGPUSIM_ROOT)/src/intersim/libintersim.a - $(CPP) $(CFLAGS) -g $(notdir $(SIM_OBJS)) -L$(GPGPUSIM_ROOT)/libcuda/ -lcuda \ - -L$(LIBDIR) -l$(CUTIL) \ - -L$(GPGPUSIM_ROOT)/src/ -lgpgpusim \ - -L$(GPGPUSIM_ROOT)/src/intersim -lintersim \ - -L$(GPGPUSIM_ROOT)/src/cuda-sim/ -lgpgpu_ptx_sim \ - $(NEWLIBDIR) $(LIB) -o gpgpu_ptx_sim__$(EXECUTABLE) - rm -rf $(INTERMED_FILES) *.cubin cubin.bin *_o *.hash $(EXECUTABLE) +# architecture flag for cubin build +CUBIN_ARCH_FLAG := -%.cpp_o: %.cpp - $(CPP) $(CCFLAGS) $(INCFLAGEXTRA) -I$(CUDAHOME)/include -I$(SDKINCDIR) -L$(LIBDIR) -g -c $< -o $(notdir $@) +# OpenGL is used or not (if it is used, then it is necessary to include GLEW) +ifeq ($(USEGLLIB),1) -%.c_o: %.c - $(CC) $(CFLAGS) $(INCFLAGEXTRA) -I$(CUDAHOME)/include -I$(SDKINCDIR) -L$(LIBDIR) -g -c $< -o $(notdir $@) + ifneq ($(DARWIN),) + OPENGLLIB := -L/System/Library/Frameworks/OpenGL.framework/Libraries -lGL -lGLU $(COMMONDIR)/lib/$(OSLOWER)/libGLEW.a + else + OPENGLLIB := -lGL -lGLU -lX11 -lXi -lXmu -%.cu_o: %.cu - nvcc $(CUFLAGS) -c -arch sm_11 --keep --compiler-options -fno-strict-aliasing \ - -I. -I$(CUDAHOME)/include/ -I$(SDKINCDIR) \ - $(INCFLAGEXTRA) -L$(LIBDIR) -lcutil -DUNIX $< -o $(EXECUTABLE) -ifneq ($(NVCC_VERSION),1.1) - $(CC) -g -c $(notdir $<.cpp) -o $(notdir $@) + ifeq "$(strip $(HP_64))" "" + OPENGLLIB += -lGLEW -L/usr/X11R6/lib + else + OPENGLLIB += -lGLEW_x86_64 -L/usr/X11R6/lib64 + endif + endif + + CUBIN_ARCH_FLAG := -m64 +endif + +ifeq ($(USEGLUT),1) + ifneq ($(DARWIN),) + OPENGLLIB += -framework GLUT + else + OPENGLLIB += -lglut + endif +endif + +ifeq ($(USEPARAMGL),1) + PARAMGLLIB := -lparamgl$(LIBSUFFIX) +endif + +ifeq ($(USERENDERCHECKGL),1) + RENDERCHECKGLLIB := -lrendercheckgl$(LIBSUFFIX) +endif + +ifeq ($(USECUDPP), 1) + ifeq "$(strip $(HP_64))" "" + CUDPPLIB := -lcudpp + else + CUDPPLIB := -lcudpp64 + endif + + CUDPPLIB := $(CUDPPLIB)$(LIBSUFFIX) + + ifeq ($(emu), 1) + CUDPPLIB := $(CUDPPLIB)_emu + endif +endif + +# Libs +ifeq "$(strip $(HP_64))" "" + LIB := $(LIBEXTRA) -L$(CUDA_INSTALL_PATH)/lib -L$(LIBDIR) -L$(COMMONDIR)/lib/$(OSLOWER) else - $(CC) -g -c $(notdir $<.c) -o $(notdir $@) + LIB := $(LIBEXTRA) -L$(CUDA_INSTALL_PATH)/lib64 -L$(LIBDIR) -L$(COMMONDIR)/lib/$(OSLOWER) endif - $(GPGPUSIM_ROOT)/scripts/gen_ptxinfo -%.cu: %.cu.c +# If dynamically linking to CUDA and CUDART, we exclude the libraries from the LIB +ifeq ($(USECUDADYNLIB),1) + LIB += ${OPENGLLIB} $(PARAMGLLIB) $(RENDERCHECKGLLIB) $(CUDPPLIB) ${LIB} -ldl -rdynamic +else +# static linking, we will statically link against CUDA and CUDART + ifeq ($(USEDRVAPI),1) + LIB += -lcuda ${OPENGLLIB} $(PARAMGLLIB) $(RENDERCHECKGLLIB) $(CUDPPLIB) ${LIB} + else + LIB += -lcudart ${OPENGLLIB} $(PARAMGLLIB) $(RENDERCHECKGLLIB) $(CUDPPLIB) ${LIB} + endif +endif + +ifeq ($(USECUFFT),1) + ifeq ($(emu),1) + LIB += -lcufftemu + else + LIB += -lcufft + endif +endif + +ifeq ($(USECUBLAS),1) + ifeq ($(emu),1) + LIB += -lcublasemu + else + LIB += -lcublas + endif +endif + +# Lib/exe configuration +ifneq ($(STATIC_LIB),) + TARGETDIR := $(LIBDIR) + TARGET := $(subst .a,$(LIBSUFFIX).a,$(LIBDIR)/$(STATIC_LIB)) + LINKLINE = ar rucv $(TARGET) $(OBJS) +else + ifneq ($(OMIT_CUTIL_LIB),1) + LIB += -lcutil$(LIBSUFFIX) + endif + # Device emulation configuration + ifeq ($(emu), 1) + NVCCFLAGS += -deviceemu + CUDACCFLAGS += + BINSUBDIR := emu$(BINSUBDIR) + # consistency, makes developing easier + CXXFLAGS += -D__DEVICE_EMULATION__ + CFLAGS += -D__DEVICE_EMULATION__ + endif + TARGETDIR := $(BINDIR)/$(BINSUBDIR) + TARGET := $(TARGETDIR)/$(EXECUTABLE) + LINKLINE = $(LINK) -o $(TARGET) $(OBJS) $(LIB) +endif + +# check if verbose +verbose = 1 +ifeq ($(verbose), 1) + VERBOSE := +else + VERBOSE := @ +endif + +################################################################################ +# Check for input flags and set compiler flags appropriately +################################################################################ +ifeq ($(fastmath), 1) + NVCCFLAGS += -use_fast_math +endif + +ifeq ($(keep), 1) + NVCCFLAGS += -keep + NVCC_KEEP_CLEAN := *.i* *.cubin *.cu.c *.cudafe* *.fatbin.c *.ptx +endif + +ifdef maxregisters + NVCCFLAGS += -maxrregcount $(maxregisters) +endif + +# Add cudacc flags +NVCCFLAGS += $(CUDACCFLAGS) + +# Add common flags +NVCCFLAGS += $(COMMONFLAGS) +CXXFLAGS += $(COMMONFLAGS) +CFLAGS += $(COMMONFLAGS) + +ifeq ($(nvcc_warn_verbose),1) + NVCCFLAGS += $(addprefix --compiler-options ,$(CXXWARN_FLAGS)) + NVCCFLAGS += --compiler-options -fno-strict-aliasing +endif + +################################################################################ +# Set up object files +################################################################################ +OBJDIR := $(ROOTOBJDIR)/$(BINSUBDIR) +OBJS += $(patsubst %.cpp,$(OBJDIR)/%.cpp.o,$(notdir $(CCFILES))) +OBJS += $(patsubst %.c,$(OBJDIR)/%.c.o,$(notdir $(CFILES))) +OBJS += $(patsubst %.cu,$(OBJDIR)/%.cu.o,$(notdir $(CUFILES))) + +################################################################################ +# Set up cubin output files +################################################################################ +CUBINDIR := $(SRCDIR)data +CUBINS += $(patsubst %.cu,$(CUBINDIR)/%.cubin,$(notdir $(CUBINFILES))) + +################################################################################ +# Set up PTX output files +################################################################################ +PTXDIR := $(SRCDIR)data +PTXBINS += $(patsubst %.cu,$(PTXDIR)/%.ptx,$(notdir $(PTXFILES))) + +################################################################################ +# Rules +################################################################################ +$(OBJDIR)/%.c.o : $(SRCDIR)%.c $(C_DEPS) + $(VERBOSE)$(CC) $(CFLAGS) -o $@ -c $< + +$(OBJDIR)/%.cpp.o : $(SRCDIR)%.cpp $(C_DEPS) + $(VERBOSE)$(CXX) $(CXXFLAGS) -o $@ -c $< + +$(OBJDIR)/%.cu.o : $(SRCDIR)%.cu $(CU_DEPS) + $(VERBOSE)$(NVCC) $(NVCCFLAGS) $(SMVERSIONFLAGS) -o $@ -c $< + +$(CUBINDIR)/%.cubin : $(SRCDIR)%.cu cubindirectory + $(VERBOSE)$(NVCC) $(CUBIN_ARCH_FLAG) $(NVCCFLAGS) $(SMVERSIONFLAGS) -o $@ -cubin $< + +$(PTXDIR)/%.ptx : $(SRCDIR)%.cu ptxdirectory + $(VERBOSE)$(NVCC) $(CUBIN_ARCH_FLAG) $(NVCCFLAGS) $(SMVERSIONFLAGS) -o $@ -ptx $< + +# +# The following definition is a template that gets instantiated for each SM +# version (sm_10, sm_13, etc.) stored in SMVERSIONS. It does 2 things: +# 1. It adds to OBJS a .cu_sm_XX.o for each .cu file it finds in CUFILES_sm_XX. +# 2. It generates a rule for building .cu_sm_XX.o files from the corresponding +# .cu file. +# +# The intended use for this is to allow Makefiles that use common.mk to compile +# files to different Compute Capability targets (aka SM arch version). To do +# so, in the Makefile, list files for each SM arch separately, like so: +# +# CUFILES_sm_10 := mycudakernel_sm10.cu app.cu +# CUFILES_sm_12 := anothercudakernel_sm12.cu +# +define SMVERSION_template +OBJS += $(patsubst %.cu,$(OBJDIR)/%.cu_$(1).o,$(notdir $(CUFILES_$(1)))) +$(OBJDIR)/%.cu_$(1).o : $(SRCDIR)%.cu $(CU_DEPS) + $(VERBOSE)$(NVCC) -o $$@ -c $$< $(NVCCFLAGS) -arch $(1) +endef + +# This line invokes the above template for each arch version stored in +# SM_VERSIONS. The call funtion invokes the template, and the eval +# function interprets it as make commands. +$(foreach smver,$(SM_VERSIONS),$(eval $(call SMVERSION_template,$(smver)))) + +$(TARGET): makedirectories $(OBJS) $(CUBINS) $(PTXBINS) Makefile + $(VERBOSE)$(LINKLINE) + +cubindirectory: + $(VERBOSE)mkdir -p $(CUBINDIR) + +ptxdirectory: + $(VERBOSE)mkdir -p $(PTXDIR) + +makedirectories: + $(VERBOSE)mkdir -p $(LIBDIR) + $(VERBOSE)mkdir -p $(OBJDIR) + $(VERBOSE)mkdir -p $(TARGETDIR) + + +tidy : + $(VERBOSE)find . | egrep "#" | xargs rm -f + $(VERBOSE)find . | egrep "\~" | xargs rm -f -clean: - rm -f $(INTERMED_FILES) *.cubin *.o *_o *.hash *.ptx *.ptxinfo cubin.bin $(EXECUTABLE) gpgpu_ptx_sim__$(EXECUTABLE) +clean : tidy + $(VERBOSE)rm -f $(OBJS) + $(VERBOSE)rm -f $(CUBINS) + $(VERBOSE)rm -f $(PTXBINS) + $(VERBOSE)rm -f $(TARGET) + $(VERBOSE)rm -f $(NVCC_KEEP_CLEAN) +clobber : clean + $(VERBOSE)rm -rf $(ROOTOBJDIR) |
