how do I dispatch the functions that generated by halide (tutorial lesson 15)? - halide

The tutorial generates 3 functions with different target and pack into a single static library along with halide runtime.
The question is, how do I call it ?
To my understanding, I should check the cpu feature before calling the functions.
What is the best way the dispatch these functions ?
./lesson_15_generate \
-g my_first_generator \
-f my_first_generator_basic \
-e object,c_header\
-o . \
target=host-x86-64-no_runtime
./lesson_15_generate \
-g my_first_generator \
-f my_first_generator_sse41 \
-e object,c_header\
-o . \
target=host-x86-64-sse41-no_runtime
./lesson_15_generate \
-g my_first_generator \
-f my_first_generator_avx \
-e object,c_header\
-o . \
target=host-x86-64-avx-no_runtime

You can get Halide to do the dispatch for you at runtime using a comma-separated list of targets:
./lesson_15_generate \
-g my_first_generator \
-f my_first_generator \
-e static_library,c_header\
-o . \
target=x86-64-avx-no_runtime,x86-64-sse41-no_runtime,x86-64-no_runtime
That makes it compile three different pieces of code for the three targets. Calling "my_first_generator" will then automatically dispatch to the first thing in the list that it thinks it can run, based on checking the CPU ID on the first call.

Related

How to get the tail of `$^` in Makefile

I have the following rule in a Makefile
%/collapsed_flow_profile.png: \
code/piv/plot_collapsed_flow_profiles.R \
%/experiment2/averaged_flow_profile.csv \
%/experiment3/averaged_flow_profile.csv \
%/experiment4/averaged_flow_profile.csv \
%/experiment6/averaged_flow_profile.csv \
%/experiment7/averaged_flow_profile.csv
code/piv/plot_collapsed_flow_profiles.R \
$*/collapsed_flow_profile.png \
$*/experiment2/averaged_flow_profile.csv \
$*/experiment3/averaged_flow_profile.csv \
$*/experiment4/averaged_flow_profile.csv \
$*/experiment6/averaged_flow_profile.csv \
$*/experiment7/averaged_flow_profile.csv
As you can see, I'm passing all the dependencies except the first one as an argument to the code used in the recipe. Since $^ automatic variable contains all the dependencies, it is possible to remove the first dependency from $^ and pass it to the code as an argument?
There are $(firstword a b c) -> a and $(filter-out ...) and $(wordlist s,e,text) functions for transforming text. Combining them might be able to do what you want. The excellent documentation has the details.
PS: What happened to experiment 5? Outlier? Does not fit expectations? :-)

Clean redundant files

Well i have a pipeline which runs some data for me with the help of a makefile.
This pipeline creates an enormous amount of redundant files which i want to clean.
I have 1 makefile to run the pipeline. And the pipeline itself is connected to much other makefiles. so i added this code to the pipeline chipcap.mk file:
.PHONY cleanintermediate
cleanintermediate: $(CHIPCAP_OUTPUT)
rm -rf $(SAMPLE)clipsync.trimsync.fastq
rm -rf $(SAMPLE)clipsync.fastq
rm -rf $(SAMPLE)clip.fastq
rm -rf $(SAMPLE).fastq
rm -rf $(SAMPLE).wig && $(RM) -rf $(SAMPLE).wig.idx
rm -rf $(SAMPLE).sam
Now i run my file like this make -f run_samples.mk
This script will invoke the pipeline and start running all samples separately the command that run_samples.mk gives to the pipeline is:
all: pool1_negCTRL pool1R2R1 pool1SP1 pool2Posctrl pool2R2R2 pool2Input
getCommand = $(MAKE) -f /data/DIV5/SASC/project-064-ronald-svdz/analysis/pipelines/chipcap/chipcap.mk \
IN_DIR=/data/DIV5/SASC/project-064-ronald-svdz/input/$(1) \
OUT_DIR=/data/DIV5/SASC/project-064-ronald-svdz/analysis/runs/$(2) \
CHIPCAP_VER=0.1.2 \
FASTQ_EXT=fastq \
CHIPCAP_INPUT=$(3) \
CHIPCAP_QC_MODE=cliptrim \
GZIP_EXT=gz \
MACS14_EXE=/home/sajvanderzeeuw/.virtualenvs/ronald/bin/macs \
PYTHON_EXE=/home/sajvanderzeeuw/.virtualenvs/ronald/bin/python2.7 \
OPT_MACS14_mfold=$(4),$(5)
#OPT_MACS14_control=control.bam
#Negative control sample
pool1_negCTRL:
$(call getCommand,pool1,pool1_negCTRL_monday_test,pool1-negCTRL_S1_L001_R1_001.fastq.gz,15,30)
How can i say to run_samples.mk that also cleanintermediate(which is in chipcap.mk) should be executed. I've been puzzling a lot but cant find the right way to do it.
cleanintermediate: $(CHIPCAP_OUTPUT)
in chipcap.mk should become cleanintermediate: all
In runchipcap.mk add cleanintermediate to getCommand
getCommand = $(MAKE) -f /data/DIV5/SASC/project-064-ronald-svdz/analysis/pipelines/chipcap/chipcap.mk \
IN_DIR=/data/DIV5/SASC/project-064-ronald-svdz/input/$(1) \
OUT_DIR=/data/DIV5/SASC/project-064-ronald-svdz/analysis/runs/$(2) \
CHIPCAP_VER=0.1.2 \
FASTQ_EXT=fastq \
CHIPCAP_INPUT=$(3) \
CHIPCAP_QC_MODE=cliptrim \
GZIP_EXT=gz \
MACS14_EXE=/home/sajvanderzeeuw/.virtualenvs/ronald/bin/macs \
PYTHON_EXE=/home/sajvanderzeeuw/.virtualenvs/ronald/bin/python2.7 \
OPT_MACS14_mfold=$(4),$(5) cleanintermediate
#OPT_MACS14_control=control.bam

Creating a zip for my app in bash script

I'm trying to use Xcode 5 bots for my Continuos Integration. I need to create a zip-file of my app-file.
In my scheme under Archive I use this script:
LATESTBUILD=$(ls -1rt /Library/Server/Xcode/Data/BotRuns | tail -1)
APP="/Library/Server/Xcode/Data/BotRuns/${LATESTBUILD}/output/Archive.xcarchive/Products/Applications/${PRODUCT_NAME}.app"
echo "Zipping .app for ${PRODUCT_NAME}"
/usr/bin/zip -r "${APP}.zip" "${APP}"
echo "Sending to *HockeyApp*"
curl \
-F "status=2" \
-F "notify=0" \
-F "notes=Testing CI" \
-F "notes_type=0" \
-F "ipa=${APP}.zip" \
-H "X-HockeyAppToken: myToken \
https://rink.hockeyapp.net/api/2/apps/myAppID/app_versions/upload
This will create a .zip-file. However, not the actual app but the whole folder structure for ${app}.
How can I create a zip-file that only contains the actual app?
To specify a file parameter with curl, you have to prefix the filename with #. Correct would be:
echo "Sending to *HockeyApp*"
curl \
-F "status=2" \
-F "notify=0" \
-F "notes=Testing CI" \
-F "notes_type=0" \
-F "ipa=#${APP}.zip" \
-H "X-HockeyAppToken: myToken \
https://rink.hockeyapp.net/api/2/apps/myAppID/app_versions/upload
Fixed this by stepping in to the directory before zipping it.
cd "/tmp/Archive.xcarchive/Products/Applications/"

Building with Build.exe and dirs/sources and Visual Studio 2010/11

Is there any way to tell Visual Studio 2010 (or Visual Studio 11 Developer Preview) to use a sources file?
Is there any tools for converting from nmake/dirs/sources to MSBuild?
I really want to use the Visual Studio 11 Developer Preview Code Analysis tools on a very old C++ solution, which currently doesn't even come close to being able to compile in Visual Studio.
Here's an example of one of the many sources files:
!INCLUDE $(INETROOT)\build\paths.all
!INCLUDE $(INETROOT)\build\sources.all
TARGETNAME=CSDWCtlg
TARGETTYPE=DYNLINK
DLLENTRY=DllMainCRTStartupCustom
DLLDEF=
USE_NATIVE_EH=1
NO_NTDLL=1
NTTARGETFILE0=$(EXPORTED_FILES)
INCLUDES= \
$(INCLUDES); \
$(SDK_INC_PATH); \
$(ATL_INC_PATH); \
$(CSSTORAGE)\inc; \
$(CSSTORAGE)\util\inc; \
$(CSSTORAGE)\dbg; \
$(CSSTORAGE)\msg; \
$(CSSTORAGE)\intf\idl; \
$(CSSTORAGE)\ctlg; \
$(CSSTORAGE)\provider; \
$(CSSTORAGE)\dsproviders\inc\; \
$(CSCOMMON)\rockall4\Build\Rockall\Include; \
$(CSCOMMON)\rockall4\Code\Rockall\Interface; \
$(CSCOMMON)\kbase; \
$(CSCOMMON)\inc; \
# goes to both RC compiler and C compiler
# RUN_WPP=$(SOURCES) -func:{LEVEL=Error}ErrorTrace(ERR,MSG,...) -func:{LEVEL=Debug}DebugTrace(DBG,MSG,...)
C_DEFINES=$(C_DEFINES) /D_UNICODE /DUNICODE /DPROJ_METABASE /DCSTRACE_CSDWCTLG /D_CTLG_DIAGNOSTIC#1
USER_C_FLAGS=$(USER_C_FLAGS) -D_CTLG_DIAGNOSTIC=1 -GR -D_WIN32_WINNT=0x0500 -DOLEDBVER=0x0250
# check for 64-bit compatiblitly
!if "$(PROCESSOR_ARCHITECTURE)"=="x86"
USER_C_FLAGS = $(USER_C_FLAGS) /Wp64
!endif
# The line below includes the common build flags.
# It modifies the USER_C_FLAGS variable by appending the 'project' level flags.
# Be sure to use the syntax USER_C_FLAGS=$(USER_C_FLAGS) 'flags' if you use USER_C_FLAGS after this include.
!INCLUDE $(CSSTORAGE)\inc\userFlags$(DCRT).inc
USE_MSVCRT=1
PRECOMPILED_CXX=1
PRECOMPILED_INCLUDE=pch.hpp
PRECOMPILED_PCH=pch_hpp.pch
PRECOMPILED_OBJ=pch_hpp.obj
SOURCES=\
csdwctlg.rc \
pch.cpp \
dll.cpp \
crow.cpp \
ctlgdump.cpp \
ctlghandler.cpp \
ctlgobj.cpp \
ctlgobjaccess.cpp \
ctlgobjclsdef.cpp \
ctlgobjdefs.cpp \
ctlgobjget.cpp \
ctlgobjkeydef.cpp \
ctlgobjmemdef.cpp \
ctlgobjrel.cpp \
ctlgobjrow.cpp \
ctlgobjset.cpp \
ctlgobjtbl.cpp \
ctlgobjtbls.cpp \
ctlgobjtypedef.cpp \
ctlgobjview.cpp \
ctlgpersist.cpp \
ctlgresolve.cpp \
ctlgresolve2.cpp \
ctlgpartresolve.cpp \
ctlgaggrresolve.cpp \
ctlgfilterresolve.cpp \
ctlgvalidate.cpp \
expschema.cpp \
mbcatalog.cpp \
mbictlgchg.cpp \
schemamgr.cpp \
sqlpathtrans.cpp \
TARGETLIBS= \
$(DEFAULTLIBS) \
$(SDK_LIB_PATH)\ole32.lib \
$(SDK_LIB_PATH)\oleaut32.lib \
$(SDK_LIB_PATH)\uuid.lib \
$(SDK_LIB_PATH)\urlmon.lib \
$(TARGETPATH)\*\CSDWIntf.lib \
$(TARGETPATH)\*\CSDWUtil.lib \
$(SDK_LIB_PATH)\msi.lib \
$(TARGETPATH)\*\csrockall.lib \
$(TARGETPATH)\*\CSDWSrvrDLL.lib \
$(SDK_LIB_PATH)\Kernel32.lib \
$(SDK_LIB_PATH)\user32.lib \
$(SDK_LIB_PATH)\Advapi32.lib \
$(CRT_LIB_PATH)\oldnames.lib \
$(SDK_LIB_PATH)\atls$(DCRT).lib \
# For Binplacing
MISCFILES= \
.\SCHEMA\* \
Any advice?
UPDATE: I've found nmake2msbuild.exe which is part of the WDK. It is intended for driver development and converts dirs and sources to MSBuild projects. I am not sure if it's going to work for what I have to do (not drivers), but I'm going to give it a try.
I've found nmake2msbuild.exe which is part of the WDK. It is intended for driver development and converts dirs and sources to MSBuild projects.
Some manual tweaking of the sources files was required to get the tool to complete conversion. It doesn't do everything, but helps get things on track.

How to get better performance with Qt4.5 on arm platform

I just finished porting the QT4.5.3 GUI lib with touchscreen lib tslib1.4.1 to arm9 based S3C2440;but I find programs are running slow.How to make Qt4.5.3 run more smoothly?
I have already read the references on http://doc.trolltech.com/4.7-snapshot/fine-tuning-features.html and http://doc.trolltech.com/4.7-snapshot/qt-performance.html Any other suggestion according to your experience?Thanks!
I use the S3C24xx too. I use Qt 4.6.2. Here is my compile configuration
#host:/qt-everywhere-opensource-src-4.6.2#./configure \
-opensource \
-confirm-license \
-release -shared \
-embedded arm \
-xplatform qws/linux-arm-g++ \
-depths 16,18,24 \
-fast \
-optimized-qmake \
-pch \
-qt-sql-sqlite \
-qt-libjpeg \
-qt-zlib \
-qt-libpng \
-qt-freetype \
-little-endian -host-little-endian \
-no-qt3support \
-no-libtiff -no-libmng \
-no-opengl \
-no-mmx -no-sse -no-sse2 \
-no-3dnow \
-no-openssl \
-no-webkit \
-no-qvfb \
-no-phonon \
-no-nis \
-no-opengl \
-no-cups \
-no-glib \
-no-xcursor -no-xfixes -no-xrandr -no-xrender \
-no-separate-debug-info \
-nomake examples -nomake tools -nomake docs \
-qt-mouse-tslib -I/usr/local/tslib/include -L/usr/local/tslib/lib
#host:/qt-everywhere-opensource-src-4.6.2# make
#host:/qt-everywhere-opensource-src-4.6.2# make install
Also notice that, if you change optimization level of compiler in file qt-everywhere-opensource-src-4.6.2/mkspecs/common/g++.conf from -O2 to -O0 may cause the Qt library run very slow.
Hope it is useful for you.
I suggest running a profiling tool to see what your program is actually doing. It might be that another part of your program is hogging the CPU. Performance problems are often first noticed through the GUI since it is something that the user sees and interacts with. Oprofile is a good tool to try out.

Resources