forked from halide/Halide
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathINSTALL
128 lines (96 loc) · 5.37 KB
/
INSTALL
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
------------------------------------------------------------------
Dependencies
------------------------------------------------------------------
Building halide requires at least llvm 3.2, along with the matching
version of clang. llvm-config and clang must be somewhere in the
path. If your OS does not have packages for llvm-3.2, you can find
binaries for it at http://llvm.org/releases/download.html. Download an
appropriate package and then either install it, or at least put the
bin subdirectory in your path. (This works well on OS X and Ubuntu.)
If you want to build it yourself, first check it out from subversions:
svn co https://llvm.org/svn/llvm-project/llvm/branches/release_32 llvm3.2
svn co https://llvm.org/svn/llvm-project/cfe/branches/release_32 llvm3.2/tools/clang
Then build it like so:
cd llvm3.2
./configure --enable-optimized --enable-assertions --with-clang --enable-targets=x86,arm,nvptx
make -j8
Then finally tell Halide's Makefile about it like so:
export LLVM_CONFIG=<path to llvm>/Release+Asserts/bin/llvm-config
export CLANG=<path to llvm>/Release+Asserts/bin/clang
If you want a newer llvm, then trunk llvm should also work.
------------------------------------------------------------------
Building Halide
------------------------------------------------------------------
With LLVM_CONFIG and CLANG set (or the appropriate llvm-config and
clang in your path), you should be able to just run 'make' in this
directory. 'make run_tests' will run the JIT test suite, and 'make
test_apps' will make sure all the apps compile and run (but won't
check their output).
There is no 'make install' yet. If you want to make an install
package, run 'make distrib'.
------------------------------------------------------------------
Building Halide with Native Client support
------------------------------------------------------------------
Compiling to Native Client is an experimental feature. JIT compilation
is not supported, only generating object files. Only native targets
are supported, not Portable Native Client (PNaCl). The PNaCl llvm tree
is used as it contains required llvm headers and libraries for compiling
to the Native Client target.
In order to build Halide with Native Client support, one will need the
PNaCl llvm tree from:
http://git.chromium.org/native_client/pnacl-llvm.git
and, for good measure, PNaCl's version of clang:
http://git.chromium.org/native_client/pnacl-clang.git
To check these out:
% git clone http://git.chromium.org/native_client/pnacl-llvm.git pnacl-llvm
% cd pnacl-llvm/tools
% git clone http://git.chromium.org/native_client/pnacl-clang.git clang
% cd ../..
To enable all Halide targets, build it like so:
% mkdir build
% cd build
% cmake -DLLVM_TARGETS_TO_BUILD="X86;ARM;NVPTX" -DLLVM_ENABLE_ASSERTIONS=ON -DCMAKE_BUILD_TYPE=Release ..
% make -j8
It will possibly be helpful to get the entire dev tree for
PNaCl. Documentation for this is here:
http://www.chromium.org/nativeclient/pnacl/developing-pnacl
A standard Native Client tree will also be required for the C library
includes to build the runtime initial modules. (Only glibc has been
tried, not newlib.) Likely the easiest way to get this is to download
the Native Client SDK from here:
https://developers.google.com/native-client/sdk/
Once The Native Client prerequisites are in place, set the following
variables (on the command line or by editing the Makefile):
Point LLVM_CONFIG to the llvm-config that lives in your pnacl llvm
build. E.g:
% export LLVM_CONFIG=<path-to-Halide>/llvm/pnacl-llvm/build/bin/llvm-config
Change WITH_NATIVE_CLIENT to "true" (or any non-empty value):
% export WITH_NATIVE_CLIENT=true
Point NATIVE_CLIENT_X86_INCLUDE and NATIVE_CLIENT_ARM_INCLUDE to the
appropriate include directories within the native client SDK. E.g.:
% export NATIVE_CLIENT_X86_INCLUDE=~/nacl_sdk/pepper_26/toolchain/linux_x86_glibc/x86_64-nacl/include/
% export NATIVE_CLIENT_ARM_INCLUDE=~/nacl_sdk/pepper_26/toolchain/linux_arm_newlib/arm-nacl/include/
With these variables set, run make. This will build a Halide lib
capable of generating native client objects. Neither the tests nor
most of the apps Makefiles have been updated to work with cross
compilation however. Try the app HelloNacl for a theoretically-working
example.
ARM native client has not been tested yet.
------------------------------------------------------------------
Building Halide and llvm as 32-bit on 64-bit linux
------------------------------------------------------------------
This is necessary if you want to JIT compile 32-bit code. It is not
necessary for AOT compiling 32-bit Halide pipelines. The 64-bit
version of Halide cross-compiles 32-bit code just fine.
To get a 32-bit llvm, configure and compile it like so:
% CC="gcc -m32" CXX="g++ -m32" ./configure --enable-targets=x86,arm,nvptx --enable-assertions --enable-optimized --build=i686-pc-linux-gnu
% CC="gcc -m32" CXX="g++ -m32" make
To generate a 32-bit Halide, compile it like so:
% HL_TARGET=x86-32 LD="ld -melf_i386" CC="gcc -m32" CXX="g++ -m32" make
You should then be able to run the JIT tests with a 32-bit target:
% CXX="g++ -m32 -msse4" make build_tests
% HL_TARGET=x86-32-sse41 make run_tests
If you have a 32-bit libpng, you can also run the apps in 32-bit:
% HL_TARGET=x86-32-sse41 CXX="g++ -m32 -msse4" make test_apps
The tests should pass, but the tutorials will fail to compile unless
you manually supply a 32-bit libpng.