Skip to content

event register error on extrae call c type conversion #11

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
clasqui opened this issue Feb 23, 2023 · 10 comments
Closed

event register error on extrae call c type conversion #11

clasqui opened this issue Feb 23, 2023 · 10 comments
Labels
bug Something isn't working help wanted Extra attention is needed

Comments

@clasqui
Copy link
Contributor

clasqui commented Feb 23, 2023

When registering an event type, this error arises:

ERROR: LoadError: MethodError: Cannot `convert` an object of type Base.RefValue{Vector{Int64}} to an object of type UInt64
Closest candidates are:
  convert(::Type{T}, ::T) where T<:Number at number.jl:6
  convert(::Type{T}, ::Number) where T<:Number at number.jl:7
  convert(::Type{T}, ::Base.TwicePrecision) where T<:Number at twiceprecision.jl:250
  ...
Stacktrace:
  [1] Base.RefValue{UInt64}(x::Base.RefValue{Vector{Int64}})
    @ Base ./refvalue.jl:8
  [2] convert(#unused#::Type{Ref{UInt64}}, x::Base.RefValue{Vector{Int64}})
    @ Base ./refpointer.jl:104
  [3] cconvert(T::Type, x::Base.RefValue{Vector{Int64}})
    @ Base ./essentials.jl:396
  [4] Extrae_define_event_type(type::Int64, type_description::String, nvalues::Int64, values::Base.RefValue{Vector{Int64}}, values_description::Base.RefValue{Vector{String}})
    @ Extrae.FFI ~/Documents/BePPP/cobrexa/Extrae.jl/src/FFI.jl:134
  [5] register(events::Vector{Event{400001, ValueCode} where ValueCode}, desc::String)
    @ Extrae ~/Documents/BePPP/cobrexa/Extrae.jl/src/API.jl:140
  [6] register
    @ ~/Documents/BePPP/cobrexa/Extrae.jl/src/API.jl:132 [inlined]
  [7] init()
    @ Extrae ~/Documents/BePPP/cobrexa/Extrae.jl/src/API.jl:37
  [8] addprocs_extrae(np::Int64; restrict::Bool, kwargs::Base.Iterators.Pairs{Union{}, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
    @ Extrae ~/Documents/BePPP/cobrexa/Extrae.jl/src/Instrumentation/Distributed.jl:124
  [9] addprocs_extrae(np::Int64)
    @ Extrae ~/Documents/BePPP/cobrexa/Extrae.jl/src/Instrumentation/Distributed.jl:120
 [10] top-level scope
    @ ~/Documents/BePPP/cobrexa/Extrae.jl/scripts/test-distributed-work.jl:4

The cause seems to be the conversion of the vector of event values from Ref(Vector{Int64}) to Uint64, which is the type specified in

Extrae_define_event_type(type, type_description, nvalues, values, values_description) = @ccall lib.Extrae_define_event_type(type::Ref{Type}, type_description::Cstring, nvalues::Ref{UInt32}, values::Ref{Value}, values_description::Ptr{Ptr{UInt8}})::Cvoid
for the vlaues parameter.

My thought here is that Julia is not interpreting the vector as a pointer, which is something that we straightforward do in C.

@clasqui clasqui added bug Something isn't working help wanted Extra attention is needed labels Feb 23, 2023
@clasqui
Copy link
Contributor Author

clasqui commented Feb 23, 2023

My suggestion here is that, instead of letting @ccall implicitly convert types, we expand the function in FFI to do ourselves the conversion

@mofeing
Copy link
Member

mofeing commented Feb 23, 2023

I don't think that is necessary. We just need to tell correctly the type.
My guess is that instead of

..., values::Ref{Value}, ...

it should be

..., values::Ref{Vector{Value}}, ...

Can you try that?

@clasqui
Copy link
Contributor Author

clasqui commented Feb 23, 2023

Yep, this is what I already tried yesterday in PR #12
This solves the conversion for the values parameter, but then another issue with the conversion of the descs strings vector appears

@mofeing
Copy link
Member

mofeing commented Feb 23, 2023

Nice! Good catch. Merging now.

@clasqui
Copy link
Contributor Author

clasqui commented Feb 23, 2023

Wait @mofeing !! This was not the only issue with the type conversion in register 😅 after ai solved the first one, another one appeared! That's what I wanted to discuss with you

@clasqui clasqui reopened this Feb 23, 2023
@mofeing
Copy link
Member

mofeing commented Feb 23, 2023

Ahh, okok. Tell me.

@clasqui
Copy link
Contributor Author

clasqui commented Feb 23, 2023

Next one is relative to the conversion of the descs parameter:

ERROR: LoadError: MethodError: no method matching unsafe_convert(::Type{Ptr{Ptr{UInt8}}}, ::Base.RefValue{Vector{String}})
Closest candidates are:
  unsafe_convert(::Type{Ptr{Tv}}, ::SuiteSparse.CHOLMOD.Sparse{Tv}) where Tv at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.6/SuiteSparse/src/cholmod.jl:296
  unsafe_convert(::Type{Ptr{T}}, ::LinearAlgebra.Transpose{var"#s814", var"#s813"} where {var"#s814", var"#s813"<:(AbstractVecOrMat{T} where T)}) where T at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.6/LinearAlgebra/src/adjtrans.jl:222
  unsafe_convert(::Type{Ptr{T}}, ::SharedArrays.SharedArray{T, N} where N) where T at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.6/SharedArrays/src/SharedArrays.jl:361
  ...
Stacktrace:
 [1] Extrae_define_event_type(type::Int64, type_description::String, nvalues::Int64, values::Vector{Int64}, values_description::Base.RefValue{Vector{String}})
   @ Extrae.FFI ~/Documents/BePPP/cobrexa/Extrae.jl/src/FFI.jl:134
 [2] register(events::Vector{Event{400001, ValueCode} where ValueCode}, desc::String)
   @ Extrae ~/Documents/BePPP/cobrexa/Extrae.jl/src/API.jl:139
 [3] register
   @ ~/Documents/BePPP/cobrexa/Extrae.jl/src/API.jl:132 [inlined]
 [4] init()
   @ Extrae ~/Documents/BePPP/cobrexa/Extrae.jl/src/API.jl:37
 [5] addprocs_extrae(np::Int64; restrict::Bool, kwargs::Base.Iterators.Pairs{Union{}, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
   @ Extrae ~/Documents/BePPP/cobrexa/Extrae.jl/src/Instrumentation/Distributed.jl:124
 [6] addprocs_extrae(np::Int64)
   @ Extrae ~/Documents/BePPP/cobrexa/Extrae.jl/src/Instrumentation/Distributed.jl:120
 [7] top-level scope
   @ ~/Documents/BePPP/cobrexa/Extrae.jl/scripts/test-distributed-work.jl:4
in expression starting at /home/mclasca/Documents/BePPP/cobrexa/Extrae.jl/scripts/test-distributed-work.jl:4

@mofeing
Copy link
Member

mofeing commented Feb 23, 2023

I did what is suggested in https://docs.julialang.org/en/v1/manual/calling-c-and-fortran-code/

I think the solution should be similar: remove the Ref(descs) and leave only descs in the register function.

@clasqui
Copy link
Contributor Author

clasqui commented Feb 23, 2023

This shows another error, but I am not sure now if it is the same place (our solution was not correct) or another place (so we solved previous issue).

ERROR: LoadError: MethodError: no method matching String(::Int64)
Closest candidates are:
  String(::String) at boot.jl:350
  String(::Vector{UInt8}) at strings/string.jl:53
  String(::Symbol) at strings/string.jl:83
  ...
Stacktrace:
  [1] description(#unused#::Type{Event{400004, 0}})
    @ Extrae ~/Documents/BePPP/cobrexa/Extrae.jl/src/API.jl:104
  [2] description(#unused#::Event{400004, 0})
    @ Extrae ~/Documents/BePPP/cobrexa/Extrae.jl/src/API.jl:105
  [3] _broadcast_getindex_evalf
    @ ./broadcast.jl:648 [inlined]
  [4] _broadcast_getindex
    @ ./broadcast.jl:621 [inlined]
  [5] _getindex
    @ ./broadcast.jl:645 [inlined]
  [6] _getindex
    @ ./broadcast.jl:644 [inlined]
  [7] _broadcast_getindex
    @ ./broadcast.jl:620 [inlined]
  [8] getindex
    @ ./broadcast.jl:575 [inlined]
  [9] copy
    @ ./broadcast.jl:922 [inlined]
 [10] materialize
    @ ./broadcast.jl:883 [inlined]
 [11] register(events::Vector{Event{400004, ValueCode} where ValueCode}, desc::String)
    @ Extrae ~/Documents/BePPP/cobrexa/Extrae.jl/src/API.jl:138
 [12] register
    @ ~/Documents/BePPP/cobrexa/Extrae.jl/src/API.jl:132 [inlined]

@mofeing
Copy link
Member

mofeing commented Feb 23, 2023

The error happens because description(::typeof(DistributedHandleEnd)) is not defined. Uploading a fix now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants