Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions examples/juliac/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
JULIA ?= $(shell which julia)
JULIAC ?= $(shell $(JULIA) -e 'print(normpath(joinpath(Sys.BINDIR, Base.DATAROOTDIR, "julia", "juliac.jl")))')

RUNIC_FILES := $(wildcard ../src/*.jl) ../Project.toml

runicc: runicc.jl Project.toml Manifest.toml $(RUNIC_FILES) check-julia
$(JULIA) --project=. $(JULIAC) --verbose --output-exe $@ --experimental --trim=unsafe $<

Manifest.toml: Project.toml ../Project.toml
$(JULIA) --project=. -e 'using Pkg; Pkg.instantiate()'
@touch $@ # Pkg.instantiate doesn't update the mtime if there are no changes

clean:
-rm -f runicc Manifest.toml

check-julia:
@if ! $(JULIA) --help-hidden | grep -s -q '\-\-trim'; then \
echo "ERROR: The configured julia binary ($(JULIA)) does not support the --trim argument."; \
echo " Configure the binary using the JULIA variable (e.g. \`JULIA=/path/to/julia make ...\`)"; \
echo " or change how \`julia\` resolves in \`PATH\`."; \
exit 1; \
fi

print-%:
@echo '$*=$($*)'

.PHONY: clean check-julia
5 changes: 5 additions & 0 deletions examples/juliac/Project.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[deps]
MPI = "da04e1cc-30fd-572f-bb4f-1f8673147195"

[sources]
MPI = {path = "../.."}
19 changes: 19 additions & 0 deletions examples/juliac/main.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
module MPIC

# Compileable main function corresponding to `int main(int argc, char** argv)`
Base.@ccallable function main(argc::Cint, argv::Ptr{Ptr{UInt8}})::Cint
# Load command line arguments. Note that the first argument is the
# executable name so we skip it.
args = Vector{String}(undef, argc - 1)
for i in 2:argc
argptr = unsafe_load(argv, i)
arg = unsafe_string(argptr)
args[i - 1] = arg
end
return 0
end

# Tell juliac about the main entrypoint
Base.Experimental.entrypoint(main, (Cint, Ptr{Ptr{UInt8}}))

end
13 changes: 11 additions & 2 deletions src/nonblocking.jl
Original file line number Diff line number Diff line change
Expand Up @@ -190,8 +190,17 @@ Base.unsafe_convert(::Type{MPI_Request}, request::Request) = request.val
Base.unsafe_convert(::Type{Ptr{MPI_Request}}, request::Request) = convert(Ptr{MPI_Request}, pointer_from_objref(request))


const REQUEST_NULL = Request(API.MPI_REQUEST_NULL[], nothing)
add_load_time_hook!(LoadTimeHookSetVal(REQUEST_NULL, API.MPI_REQUEST_NULL))
struct NullRequest <: AbstractRequest end
const REQUEST_NULL = NullRequest()

Base.convert(::Type{Request}, ::NullRequest) =
Request(API.MPI_REQUEST_NULL[], nothing)

isnull(::NullRequest) = true
setbuffer!(::NullRequest, ::Any) = throw(ArgumentError("Cannot set buffer on NullRequest"))

# const REQUEST_NULL = Request(API.MPI_REQUEST_NULL[], nothing)
# add_load_time_hook!(LoadTimeHookSetVal(REQUEST_NULL, API.MPI_REQUEST_NULL))

"""
MPI.UnsafeRequest()
Expand Down
Loading