Preparing and building for profiling
Follow these steps to set up a sandbox-style project tree structure so you have more flexibility when modifying and generating files.
Step 1: Copy the application from the SDK tree
To work on a sandbox tree means you have your own copy of the
project on an accessible location (for example, your home directory): cp -R
/opt/cell/sdk/demos/FFT16M ~/.
Go to your recently created project structure, and locate the makefiles. You should find three of them:
- ~/FFT16M/Makefile
- ~/FFT16M/ppu/Makefile
- ~/FFT16M/spu/Makefile
Next, make a few modifications to the makefiles to prevent them from trying to install executables back to the SDK tree. Also, introduce the required compilation flags for profiling data. Listing 1 shows you how to modify the ~/FFT16M/ppu/Makefile.
Listing 1. Changing ~/FFT16M/ppu/Makefile for gcc
#######################################################################
## Target
#######################################################################
#
PROGRAM_ppu= fft
#######################################################################
## Objects
#######################################################################
#
IMPORTS = ../spu/fft_spu.a -lspe2 -lpthread -lm -lnuma
#INSTALL_DIR= $(EXP_SDKBIN)/demos
#INSTALL_FILES= $(PROGRAM_ppu)
LDFLAGS_gcc = -Wl,-q
CFLAGS_gcc = -g
#######################################################################
## buildutils/make.footer
#######################################################################
#
ifdef CELL_TOP
include $(CELL_TOP)/buildutils/make.footer
else
include ../../../../buildutils/make.footer
endif
|
Note that:
- Install directives are commented out.
- No further makefile modifications except the ones described are required.
- There are specific changes based on whether you use gcc or xlc as the compiler.
Now, look at Listing 2.
Listing 2. Changing ~/FFT16M/ppu/Makefile for gcc
#######################################################################
## Target
#######################################################################
#
PROGRAM_ppu= fft
#######################################################################
## Objects
#######################################################################
#
PPU_COMPILER = xlc
IMPORTS = ../spu/fft_spu.a -lspe2 -lpthread -lm -lnuma
#INSTALL_DIR= $(EXP_SDKBIN)/demos
#INSTALL_FILES= $(PROGRAM_ppu)
LDFLAGS_xlc = -Wl,-q
CFLAGS_xlc = -g
#######################################################################
## buildutils/make.footer
#######################################################################
#
ifdef CELL_TOP
include $(CELL_TOP)/buildutils/make.footer
else
include ../../../../buildutils/make.footer
endif
|
The code introduced the -g and
-Wl,-q compilation flags in order to preserve the
relocation and the line number information in the final integrated executable.
In Listing 3, you modify the ~/FFT16M/spu/Makefile for gcc. In Listing 4,
you modify the ~/FFT16M/spu/Makefile for xlc.
Listing 3. Changing ~/FFT16M/spu/Makefile for gcc
#######################################################################
## Target
#######################################################################
#
PROGRAMS_spu:= fft_spu
LIBRARY_embed:= fft_spu.a
#######################################################################
## Local Defines
#######################################################################
#
CFLAGS_gcc:= -g --param max-unroll-times=1 # needed to keep size of
program down
LDFLAGS_gcc = -Wl,-q -g
#######################################################################
## buildutils/make.footer
#######################################################################
#
ifdef CELL_TOP
include $(CELL_TOP)/buildutils/make.footer
else
include ../../../../buildutils/make.footer
endif
|
Listing 4. Changing ~/FFT16M/ppu/Makefile for xlc
#######################################################################
## Target
#######################################################################
#
SPU_COMPILER = xlc
PROGRAMS_spu:= fft_spu
LIBRARY_embed:= fft_spu.a
#######################################################################
## Local Defines
#######################################################################
#
CFLAGS_xlc:= -g -qnounroll -O5
LDFLAGS_xlc:= -O5 -qflag=e:e -Wl,-q -g
#######################################################################
## buildutils/make.footer
#######################################################################
#
ifdef CELL_TOP
include $(CELL_TOP)/buildutils/make.footer
else
include ../../../../buildutils/make.footer
endif
|
Before the actual build, be sure to set the default compiler accordingly by
issuing
/opt/cell/sdk/buildutils/cellsdk_select_compiler [gcc|xlc].
Now you can proceed with the build:
cd ~/FFT16M ; CELL_TOP=/opt/cell/sdk make.



