Mars: A MapReduce Framework on Graphics Processors Dedug调试

来源:互联网 发布:淘宝店铺出售平台 编辑:程序博客网 时间:2024/06/12 16:00

Mars是一个运行在gpu上的map/reduce框架,笔者最近最近想使用这个框架来做一些图处理的工作。

然而mars运行在linux+cuda平台之上,最重要的是2009年开发mars使用的cuda2.0版本,如今cuda已经发展到7.5

早期的库已经不支持。如何调试和运行mars困难重重。

接下来笔者分享运行和调试mars的一些经验。

1.我使用的unbutu版本是14.04,需要安装cuda driver和sdk(参考我的另一篇博客)

mars marInc.cu 文件用到cutil.h头文件。cuda5.0版本之后这个头文件已经不支持,必须从网上下载到这个sdk

使用当前nvcc编译生成相关静态链接库和动态链接库

2.配置makefile文件

mars自带的sample提供一下的makefile

# Add source files here
EXECUTABLE := subg_match/subg_match
# Cuda source files (compiled with cudacc)
CUFILES := main.cu MarsLib.cu MarsScan.cu MarsSort.cu
# C/C++ source files (compiled with gcc / c++)
CCFILES := MarsUtils.cpp




################################################################################
# Rules and targets


include ../../common/common.mk


注意最后引用commmon.mk makefile文件

打开这个makefile

line154-line170

# Debug/release configuration
ifeq ($(dbg),1)
COMMONFLAGS += -g
NVCCFLAGS   += -D_DEBUG
CXXFLAGS    += -D_DEBUG
CFLAGS      += -D_DEBUG
BINSUBDIR   := debug
LIBSUFFIX   := D
else 
COMMONFLAGS += -O2 
BINSUBDIR   := release
LIBSUFFIX   := 
NVCCFLAGS   += --compiler-options -fno-strict-aliasing
CXXFLAGS    += -fno-strict-aliasing
CFLAGS      += -fno-strict-aliasing
endif

Makefile执行时,首先判断dbg变量,如果dbg的值是1,编译debug版,否则编译release版。当然,默认情况下是编译release版的。

如果想编译debug版,要怎么做?

只要在执行make时,对dbg变量赋值,使得dbg的值为1,比如

# make dbg=1
需要注意的是以debug执行程序,对应的静态链接库也需要编译成debug模式,比如libcutil_x86_64D.a

这时执行make dbg=1,即可生成debug版本的程序,可以使用cuda-gdb来调试

0 0