Skip to content

Commit

Permalink
Merge pull request #18016 from JuliaLang/tb/threadcall_args_2
Browse files Browse the repository at this point in the history
Fix `@threadcall` argument passing (second try)
  • Loading branch information
maleadt authored Aug 14, 2016
2 parents 6b0bb25 + aea8180 commit b80dad4
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 0 deletions.
1 change: 1 addition & 0 deletions base/threadcall.jl
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ function do_threadcall(wrapper::Function, rettype::Type, argtypes::Vector, argva
y = cconvert(T, x)
push!(roots, y)
unsafe_store!(convert(Ptr{T}, ptr), unsafe_convert(T, y))
ptr += sizeof(T)
end

# create return buffer
Expand Down
10 changes: 10 additions & 0 deletions src/ccalltest.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ int verbose = 1;

int c_int = 0;


//////////////////////////////////
// Test for proper argument register truncation

Expand Down Expand Up @@ -520,13 +521,18 @@ JL_DLLEXPORT void finalizer_cptr(void* v)
set_c_int(-1);
}


//////////////////////////////////
// Turn off verbose for automated tests, leave on for debugging

JL_DLLEXPORT void set_verbose(int level) {
verbose = level;
}


//////////////////////////////////
// Other tests

JL_DLLEXPORT void *test_echo_p(void *p) {
return p;
}
Expand Down Expand Up @@ -723,3 +729,7 @@ JL_DLLEXPORT float32x4_t test_ppc64_vec2(int64_t d1, float32x4_t a, float32x4_t
}

#endif

JL_DLLEXPORT int threadcall_args(int a, int b) {
return a + b;
}
4 changes: 4 additions & 0 deletions test/ccall.jl
Original file line number Diff line number Diff line change
Expand Up @@ -589,6 +589,10 @@ threadcall_test_func(x) =
@test threadcall_test_func(3) == 1
@test threadcall_test_func(259) == 1

# issue 17819
# NOTE: can't use cfunction or reuse ccalltest Struct methods, as those call into the runtime
@test @threadcall((:threadcall_args, libccalltest), Cint, (Cint, Cint), 1, 2) == 3

let n=3
tids = Culong[]
@sync for i in 1:10^n
Expand Down

2 comments on commit b80dad4

@nanosoldier
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Executing the daily benchmark build, I will reply here when finished:

@nanosoldier runbenchmarks(ALL, isdaily = true)

@nanosoldier
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your benchmark job has completed - possible performance regressions were detected. A full report can be found here. cc @jrevels

Please sign in to comment.