Skip to content

Commit 4b16cc8

Browse files
committed
enable precompilation (fix #63)
1 parent d91eef8 commit 4b16cc8

File tree

5 files changed

+132
-114
lines changed

5 files changed

+132
-114
lines changed

REQUIRE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
julia 0.4-
1+
julia 0.4
22
BinDeps
33
Compat

deps/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ file(WRITE ${CMAKE_BINARY_DIR}/mpi.cmake "
144144
execute_process(COMMAND ${CMAKE_BINARY_DIR}/gen_functions OUTPUT_VARIABLE FTWOC)
145145
execute_process(COMMAND ${CMAKE_BINARY_DIR}/gen_constants OUTPUT_VARIABLE FCONS)
146146
file(READ \${SRC} MPI)
147-
file(WRITE \${DST} \"const libmpi = Libdl.dlopen(\\\"${CMAKE_LIB_INSTALL_PREFIX}/libjuliampi\\\", Libdl.RTLD_LAZY|Libdl.RTLD_DEEPBIND|Libdl.RTLD_GLOBAL)\n\")
147+
file(WRITE \${DST} \"const libmpi = \\\"${CMAKE_LIB_INSTALL_PREFIX}/libjuliampi\\\"\n\")
148148
file(APPEND \${DST} \"\n\")
149149
file(APPEND \${DST} \${FTWOC})
150150
file(APPEND \${DST} \"\n\")

deps/gen_functions.c

Lines changed: 49 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -8,55 +8,55 @@
88
int main(int argc, char *argv[])
99
{
1010
printf("const WRAPPER_VERSION = \"%s\"\n", VERSION);
11-
printf("const MPI_ABORT = Libdl.dlsym(libmpi, \"%s\")\n", STRING(MPI_ABORT));
12-
printf("const MPI_ALLGATHER = Libdl.dlsym(libmpi, \"%s\")\n", STRING(MPI_ALLGATHER));
13-
printf("const MPI_ALLGATHERV = Libdl.dlsym(libmpi, \"%s\")\n", STRING(MPI_ALLGATHERV));
14-
printf("const MPI_ALLREDUCE = Libdl.dlsym(libmpi, \"%s\")\n", STRING(MPI_ALLREDUCE));
15-
printf("const MPI_ALLTOALL = Libdl.dlsym(libmpi, \"%s\")\n", STRING(MPI_ALLTOALL));
16-
printf("const MPI_ALLTOALLV = Libdl.dlsym(libmpi, \"%s\")\n", STRING(MPI_ALLTOALLV));
17-
printf("const MPI_BARRIER = Libdl.dlsym(libmpi, \"%s\")\n", STRING(MPI_BARRIER));
18-
printf("const MPI_BCAST = Libdl.dlsym(libmpi, \"%s\")\n", STRING(MPI_BCAST));
19-
printf("const MPI_BSEND = Libdl.dlsym(libmpi, \"%s\")\n", STRING(MPI_BSEND));
20-
printf("const MPI_CANCEL = Libdl.dlsym(libmpi, \"%s\")\n", STRING(MPI_CANCEL));
21-
printf("const MPI_COMM_DUP = Libdl.dlsym(libmpi, \"%s\")\n", STRING(MPI_COMM_DUP));
22-
printf("const MPI_COMM_FREE = Libdl.dlsym(libmpi, \"%s\")\n", STRING(MPI_COMM_FREE));
23-
printf("const MPI_COMM_RANK = Libdl.dlsym(libmpi, \"%s\")\n", STRING(MPI_COMM_RANK));
24-
printf("const MPI_COMM_SIZE = Libdl.dlsym(libmpi, \"%s\")\n", STRING(MPI_COMM_SIZE));
25-
printf("const MPI_COMM_SPLIT = Libdl.dlsym(libmpi, \"%s\")\n", STRING(MPI_COMM_SPLIT));
26-
printf("const MPI_EXSCAN = Libdl.dlsym(libmpi, \"%s\")\n", STRING(MPI_EXSCAN));
27-
printf("const MPI_FINALIZE = Libdl.dlsym(libmpi, \"%s\")\n", STRING(MPI_FINALIZE));
28-
printf("const MPI_FINALIZED = Libdl.dlsym(libmpi, \"%s\")\n", STRING(MPI_FINALIZED));
29-
printf("const MPI_GATHER = Libdl.dlsym(libmpi, \"%s\")\n", STRING(MPI_GATHER));
30-
printf("const MPI_GATHERV = Libdl.dlsym(libmpi, \"%s\")\n", STRING(MPI_GATHERV));
31-
printf("const MPI_GET_COUNT = Libdl.dlsym(libmpi, \"%s\")\n", STRING(MPI_GET_COUNT));
32-
printf("const MPI_GET_PROCESSOR_NAME = Libdl.dlsym(libmpi, \"%s\")\n", STRING(MPI_GET_PROCESSOR_NAME));
33-
printf("const MPI_INIT = Libdl.dlsym(libmpi, \"%s\")\n", STRING(MPI_INIT));
34-
printf("const MPI_INITIALIZED = Libdl.dlsym(libmpi, \"%s\")\n", STRING(MPI_INITIALIZED));
35-
printf("const MPI_IPROBE = Libdl.dlsym(libmpi, \"%s\")\n", STRING(MPI_IPROBE));
36-
printf("const MPI_IRECV = Libdl.dlsym(libmpi, \"%s\")\n", STRING(MPI_IRECV));
37-
printf("const MPI_ISEND = Libdl.dlsym(libmpi, \"%s\")\n", STRING(MPI_ISEND));
38-
printf("const MPI_OP_CREATE = Libdl.dlsym(libmpi, \"%s\")\n", STRING(MPI_OP_CREATE));
39-
printf("const MPI_OP_FREE = Libdl.dlsym(libmpi, \"%s\")\n", STRING(MPI_OP_FREE));
40-
printf("const MPI_PACK = Libdl.dlsym(libmpi, \"%s\")\n", STRING(MPI_PACK));
41-
printf("const MPI_PACK_SIZE = Libdl.dlsym(libmpi, \"%s\")\n", STRING(MPI_PACK_SIZE));
42-
printf("const MPI_PROBE = Libdl.dlsym(libmpi, \"%s\")\n", STRING(MPI_PROBE));
43-
printf("const MPI_RECV = Libdl.dlsym(libmpi, \"%s\")\n", STRING(MPI_RECV));
44-
printf("const MPI_RECV_INIT = Libdl.dlsym(libmpi, \"%s\")\n", STRING(MPI_RECV_INIT));
45-
printf("const MPI_REDUCE = Libdl.dlsym(libmpi, \"%s\")\n", STRING(MPI_REDUCE));
46-
printf("const MPI_REQUEST_FREE = Libdl.dlsym(libmpi, \"%s\")\n", STRING(MPI_REQUEST_FREE));
47-
printf("const MPI_RSEND = Libdl.dlsym(libmpi, \"%s\")\n", STRING(MPI_RSEND));
48-
printf("const MPI_SCAN = Libdl.dlsym(libmpi, \"%s\")\n", STRING(MPI_SCAN));
49-
printf("const MPI_SCATTER = Libdl.dlsym(libmpi, \"%s\")\n", STRING(MPI_SCATTER));
50-
printf("const MPI_SCATTERV = Libdl.dlsym(libmpi, \"%s\")\n", STRING(MPI_SCATTERV));
51-
printf("const MPI_SEND = Libdl.dlsym(libmpi, \"%s\")\n", STRING(MPI_SEND));
52-
printf("const MPI_SEND_INIT = Libdl.dlsym(libmpi, \"%s\")\n", STRING(MPI_SEND_INIT));
53-
printf("const MPI_SSEND = Libdl.dlsym(libmpi, \"%s\")\n", STRING(MPI_SSEND));
54-
printf("const MPI_TEST = Libdl.dlsym(libmpi, \"%s\")\n", STRING(MPI_TEST));
55-
printf("const MPI_UNPACK = Libdl.dlsym(libmpi, \"%s\")\n", STRING(MPI_UNPACK));
56-
printf("const MPI_WAIT = Libdl.dlsym(libmpi, \"%s\")\n", STRING(MPI_WAIT));
57-
printf("const MPI_WAITALL = Libdl.dlsym(libmpi, \"%s\")\n", STRING(MPI_WAITALL));
58-
printf("const MPI_WAITANY = Libdl.dlsym(libmpi, \"%s\")\n", STRING(MPI_WAITANY));
59-
printf("const MPI_WTIME = Libdl.dlsym(libmpi, \"%s\")\n", STRING(MPI_WTIME));
11+
printf("const MPI_ABORT = :%s\n", STRING(MPI_ABORT));
12+
printf("const MPI_ALLGATHER = :%s\n", STRING(MPI_ALLGATHER));
13+
printf("const MPI_ALLGATHERV = :%s\n", STRING(MPI_ALLGATHERV));
14+
printf("const MPI_ALLREDUCE = :%s\n", STRING(MPI_ALLREDUCE));
15+
printf("const MPI_ALLTOALL = :%s\n", STRING(MPI_ALLTOALL));
16+
printf("const MPI_ALLTOALLV = :%s\n", STRING(MPI_ALLTOALLV));
17+
printf("const MPI_BARRIER = :%s\n", STRING(MPI_BARRIER));
18+
printf("const MPI_BCAST = :%s\n", STRING(MPI_BCAST));
19+
printf("const MPI_BSEND = :%s\n", STRING(MPI_BSEND));
20+
printf("const MPI_CANCEL = :%s\n", STRING(MPI_CANCEL));
21+
printf("const MPI_COMM_DUP = :%s\n", STRING(MPI_COMM_DUP));
22+
printf("const MPI_COMM_FREE = :%s\n", STRING(MPI_COMM_FREE));
23+
printf("const MPI_COMM_RANK = :%s\n", STRING(MPI_COMM_RANK));
24+
printf("const MPI_COMM_SIZE = :%s\n", STRING(MPI_COMM_SIZE));
25+
printf("const MPI_COMM_SPLIT = :%s\n", STRING(MPI_COMM_SPLIT));
26+
printf("const MPI_EXSCAN = :%s\n", STRING(MPI_EXSCAN));
27+
printf("const MPI_FINALIZE = :%s\n", STRING(MPI_FINALIZE));
28+
printf("const MPI_FINALIZED = :%s\n", STRING(MPI_FINALIZED));
29+
printf("const MPI_GATHER = :%s\n", STRING(MPI_GATHER));
30+
printf("const MPI_GATHERV = :%s\n", STRING(MPI_GATHERV));
31+
printf("const MPI_GET_COUNT = :%s\n", STRING(MPI_GET_COUNT));
32+
printf("const MPI_GET_PROCESSOR_NAME = :%s\n", STRING(MPI_GET_PROCESSOR_NAME));
33+
printf("const MPI_INIT = :%s\n", STRING(MPI_INIT));
34+
printf("const MPI_INITIALIZED = :%s\n", STRING(MPI_INITIALIZED));
35+
printf("const MPI_IPROBE = :%s\n", STRING(MPI_IPROBE));
36+
printf("const MPI_IRECV = :%s\n", STRING(MPI_IRECV));
37+
printf("const MPI_ISEND = :%s\n", STRING(MPI_ISEND));
38+
printf("const MPI_OP_CREATE = :%s\n", STRING(MPI_OP_CREATE));
39+
printf("const MPI_OP_FREE = :%s\n", STRING(MPI_OP_FREE));
40+
printf("const MPI_PACK = :%s\n", STRING(MPI_PACK));
41+
printf("const MPI_PACK_SIZE = :%s\n", STRING(MPI_PACK_SIZE));
42+
printf("const MPI_PROBE = :%s\n", STRING(MPI_PROBE));
43+
printf("const MPI_RECV = :%s\n", STRING(MPI_RECV));
44+
printf("const MPI_RECV_INIT = :%s\n", STRING(MPI_RECV_INIT));
45+
printf("const MPI_REDUCE = :%s\n", STRING(MPI_REDUCE));
46+
printf("const MPI_REQUEST_FREE = :%s\n", STRING(MPI_REQUEST_FREE));
47+
printf("const MPI_RSEND = :%s\n", STRING(MPI_RSEND));
48+
printf("const MPI_SCAN = :%s\n", STRING(MPI_SCAN));
49+
printf("const MPI_SCATTER = :%s\n", STRING(MPI_SCATTER));
50+
printf("const MPI_SCATTERV = :%s\n", STRING(MPI_SCATTERV));
51+
printf("const MPI_SEND = :%s\n", STRING(MPI_SEND));
52+
printf("const MPI_SEND_INIT = :%s\n", STRING(MPI_SEND_INIT));
53+
printf("const MPI_SSEND = :%s\n", STRING(MPI_SSEND));
54+
printf("const MPI_TEST = :%s\n", STRING(MPI_TEST));
55+
printf("const MPI_UNPACK = :%s\n", STRING(MPI_UNPACK));
56+
printf("const MPI_WAIT = :%s\n", STRING(MPI_WAIT));
57+
printf("const MPI_WAITALL = :%s\n", STRING(MPI_WAITALL));
58+
printf("const MPI_WAITANY = :%s\n", STRING(MPI_WAITANY));
59+
printf("const MPI_WTIME = :%s\n", STRING(MPI_WTIME));
6060

6161
return 0;
6262
}

src/MPI.jl

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,18 @@
1+
__precompile__()
2+
13
module MPI
24

35
using Compat
46

5-
include("../deps/src/compile-time.jl")
7+
const depfile = joinpath(dirname(@__FILE__), "..", "deps", "src", "compile-time.jl")
8+
isfile(depfile) || error("MPI not properly installed. Please run Pkg.build(\"MPI\")")
9+
include(depfile)
610
include("mpi-base.jl")
711
include("cman.jl")
812

13+
function __init__()
14+
# need to open libmpi with RTLD_GLOBAL flag for Linux, before any ccall
15+
Libdl.dlopen(libmpi, Libdl.RTLD_LAZY|Libdl.RTLD_DEEPBIND|Libdl.RTLD_GLOBAL)
16+
end
17+
918
end

0 commit comments

Comments
 (0)