How can I allocate a buffer contains different types of data (for MPI communication, for example)?

I don’t quite understand what you want to do. Do you want to copy the arrays into a buffer before sending with mpi? Do you create a MPI_Type_struct? What does the C-program doing this look like?

Or do you want something like this:

buf = Memory{UInt8}(undef, 32)
bufptr = pointer(buf)

ivec = unsafe_wrap(Array, Ptr{Int}(bufptr), (2,), own=false)
fvec = unsafe_wrap(Array, Ptr{Float64}(bufptr+16), (2,), own=false)

where ivec uses the first part of buf, and fvec uses the second part?

2 Likes