Skip to content

Commit

Permalink
Change function pointers to function prototypes (#695)
Browse files Browse the repository at this point in the history
* Update generated_api.jl

* Change function pointers => prototypes

ref #694

* add function pointer test

* comment comm test

Co-authored-by: t-bltg <[email protected]>
  • Loading branch information
Gnimuc and t-bltg authored Dec 19, 2022
1 parent 4b9b05f commit 3a46698
Show file tree
Hide file tree
Showing 8 changed files with 176 additions and 153 deletions.
2 changes: 1 addition & 1 deletion gen/Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ MPIPreferences = "3da0fdf6-3ccc-4f1b-acd9-58baa6c99267"
OpenMPI_jll = "fe0851c0-eecd-5654-98d4-656369965a5c"

[compat]
Clang = "0.16.11"
Clang = "0.17.1"
MPIPreferences = "0.1.3"
julia = "1.6"
26 changes: 13 additions & 13 deletions src/api/generated_api.jl
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ end
$(_doc_external(:MPI_Comm_create_keyval))
"""
function MPI_Comm_create_keyval(comm_copy_attr_fn, comm_delete_attr_fn, comm_keyval, extra_state)
@mpichk ccall((:MPI_Comm_create_keyval, libmpi), Cint, (MPI_Comm_copy_attr_function, MPI_Comm_delete_attr_function, Ptr{Cint}, MPIPtr), comm_copy_attr_fn, comm_delete_attr_fn, comm_keyval, extra_state)
@mpichk ccall((:MPI_Comm_create_keyval, libmpi), Cint, (Ptr{MPI_Comm_copy_attr_function}, Ptr{MPI_Comm_delete_attr_function}, Ptr{Cint}, MPIPtr), comm_copy_attr_fn, comm_delete_attr_fn, comm_keyval, extra_state)
end

"""
Expand Down Expand Up @@ -141,7 +141,7 @@ end
$(_doc_external(:MPI_Keyval_create))
"""
function MPI_Keyval_create(copy_fn, delete_fn, keyval, extra_state)
@mpichk ccall((:MPI_Keyval_create, libmpi), Cint, (MPI_Copy_function, MPI_Delete_function, Ptr{Cint}, MPIPtr), copy_fn, delete_fn, keyval, extra_state)
@mpichk ccall((:MPI_Keyval_create, libmpi), Cint, (Ptr{MPI_Copy_function}, Ptr{MPI_Delete_function}, Ptr{Cint}, MPIPtr), copy_fn, delete_fn, keyval, extra_state)
end

"""
Expand All @@ -159,7 +159,7 @@ end
$(_doc_external(:MPI_Type_create_keyval))
"""
function MPI_Type_create_keyval(type_copy_attr_fn, type_delete_attr_fn, type_keyval, extra_state)
@mpichk ccall((:MPI_Type_create_keyval, libmpi), Cint, (MPI_Type_copy_attr_function, MPI_Type_delete_attr_function, Ptr{Cint}, MPIPtr), type_copy_attr_fn, type_delete_attr_fn, type_keyval, extra_state)
@mpichk ccall((:MPI_Type_create_keyval, libmpi), Cint, (Ptr{MPI_Type_copy_attr_function}, Ptr{MPI_Type_delete_attr_function}, Ptr{Cint}, MPIPtr), type_copy_attr_fn, type_delete_attr_fn, type_keyval, extra_state)
end

"""
Expand Down Expand Up @@ -204,7 +204,7 @@ end
$(_doc_external(:MPI_Win_create_keyval))
"""
function MPI_Win_create_keyval(win_copy_attr_fn, win_delete_attr_fn, win_keyval, extra_state)
@mpichk ccall((:MPI_Win_create_keyval, libmpi), Cint, (MPI_Win_copy_attr_function, MPI_Win_delete_attr_function, Ptr{Cint}, MPIPtr), win_copy_attr_fn, win_delete_attr_fn, win_keyval, extra_state)
@mpichk ccall((:MPI_Win_create_keyval, libmpi), Cint, (Ptr{MPI_Win_copy_attr_function}, Ptr{MPI_Win_delete_attr_function}, Ptr{Cint}, MPIPtr), win_copy_attr_fn, win_delete_attr_fn, win_keyval, extra_state)
end

"""
Expand Down Expand Up @@ -1491,7 +1491,7 @@ end
$(_doc_external(:MPI_Comm_create_errhandler))
"""
function MPI_Comm_create_errhandler(comm_errhandler_fn, errhandler)
@mpichk ccall((:MPI_Comm_create_errhandler, libmpi), Cint, (MPI_Comm_errhandler_function, Ptr{MPI_Errhandler}), comm_errhandler_fn, errhandler)
@mpichk ccall((:MPI_Comm_create_errhandler, libmpi), Cint, (Ptr{MPI_Comm_errhandler_function}, Ptr{MPI_Errhandler}), comm_errhandler_fn, errhandler)
end

"""
Expand Down Expand Up @@ -1554,7 +1554,7 @@ end
$(_doc_external(:MPI_File_create_errhandler))
"""
function MPI_File_create_errhandler(file_errhandler_fn, errhandler)
@mpichk ccall((:MPI_File_create_errhandler, libmpi), Cint, (MPI_File_errhandler_function, Ptr{MPI_Errhandler}), file_errhandler_fn, errhandler)
@mpichk ccall((:MPI_File_create_errhandler, libmpi), Cint, (Ptr{MPI_File_errhandler_function}, Ptr{MPI_Errhandler}), file_errhandler_fn, errhandler)
end

"""
Expand Down Expand Up @@ -1590,7 +1590,7 @@ end
$(_doc_external(:MPI_Win_create_errhandler))
"""
function MPI_Win_create_errhandler(win_errhandler_fn, errhandler)
@mpichk ccall((:MPI_Win_create_errhandler, libmpi), Cint, (MPI_Win_errhandler_function, Ptr{MPI_Errhandler}), win_errhandler_fn, errhandler)
@mpichk ccall((:MPI_Win_create_errhandler, libmpi), Cint, (Ptr{MPI_Win_errhandler_function}, Ptr{MPI_Errhandler}), win_errhandler_fn, errhandler)
end

"""
Expand All @@ -1617,7 +1617,7 @@ end
$(_doc_external(:MPI_Errhandler_create))
"""
function MPI_Errhandler_create(comm_errhandler_fn, errhandler)
@mpichk ccall((:MPI_Errhandler_create, libmpi), Cint, (MPI_Comm_errhandler_function, Ptr{MPI_Errhandler}), comm_errhandler_fn, errhandler)
@mpichk ccall((:MPI_Errhandler_create, libmpi), Cint, (Ptr{MPI_Comm_errhandler_function}, Ptr{MPI_Errhandler}), comm_errhandler_fn, errhandler)
end

"""
Expand Down Expand Up @@ -1986,7 +1986,7 @@ end
$(_doc_external(:MPI_Op_create))
"""
function MPI_Op_create(user_fn, commute, op)
@mpichk ccall((:MPI_Op_create, libmpi), Cint, (MPI_User_function, Cint, Ptr{MPI_Op}), user_fn, commute, op)
@mpichk ccall((:MPI_Op_create, libmpi), Cint, (Ptr{MPI_User_function}, Cint, Ptr{MPI_Op}), user_fn, commute, op)
end

"""
Expand Down Expand Up @@ -2319,7 +2319,7 @@ end
$(_doc_external(:MPI_Grequest_start))
"""
function MPI_Grequest_start(query_fn, free_fn, cancel_fn, extra_state, request)
@mpichk ccall((:MPI_Grequest_start, libmpi), Cint, (MPI_Grequest_query_function, MPI_Grequest_free_function, MPI_Grequest_cancel_function, MPIPtr, Ptr{MPI_Request}), query_fn, free_fn, cancel_fn, extra_state, request)
@mpichk ccall((:MPI_Grequest_start, libmpi), Cint, (Ptr{MPI_Grequest_query_function}, Ptr{MPI_Grequest_free_function}, Ptr{MPI_Grequest_cancel_function}, MPIPtr, Ptr{MPI_Request}), query_fn, free_fn, cancel_fn, extra_state, request)
end

"""
Expand Down Expand Up @@ -3894,7 +3894,7 @@ end
$(_doc_external(:MPI_Op_create_c))
"""
function MPI_Op_create_c(user_fn, commute, op)
@mpichk ccall((:MPI_Op_create_c, libmpi), Cint, (MPI_User_function_c, Cint, Ptr{MPI_Op}), user_fn, commute, op)
@mpichk ccall((:MPI_Op_create_c, libmpi), Cint, (Ptr{MPI_User_function_c}, Cint, Ptr{MPI_Op}), user_fn, commute, op)
end

"""
Expand Down Expand Up @@ -4650,7 +4650,7 @@ end
$(_doc_external(:MPI_Register_datarep))
"""
function MPI_Register_datarep(datarep, read_conversion_fn, write_conversion_fn, dtype_file_extent_fn, extra_state)
@mpichk ccall((:MPI_Register_datarep, libmpi), Cint, (Ptr{Cchar}, MPI_Datarep_conversion_function, MPI_Datarep_conversion_function, MPI_Datarep_extent_function, MPIPtr), datarep, read_conversion_fn, write_conversion_fn, dtype_file_extent_fn, extra_state)
@mpichk ccall((:MPI_Register_datarep, libmpi), Cint, (Ptr{Cchar}, Ptr{MPI_Datarep_conversion_function}, Ptr{MPI_Datarep_conversion_function}, Ptr{MPI_Datarep_extent_function}, MPIPtr), datarep, read_conversion_fn, write_conversion_fn, dtype_file_extent_fn, extra_state)
end

"""
Expand Down Expand Up @@ -4983,7 +4983,7 @@ end
$(_doc_external(:MPI_Register_datarep_c))
"""
function MPI_Register_datarep_c(datarep, read_conversion_fn, write_conversion_fn, dtype_file_extent_fn, extra_state)
@mpichk ccall((:MPI_Register_datarep_c, libmpi), Cint, (Ptr{Cchar}, MPI_Datarep_conversion_function_c, MPI_Datarep_conversion_function_c, MPI_Datarep_extent_function, MPIPtr), datarep, read_conversion_fn, write_conversion_fn, dtype_file_extent_fn, extra_state)
@mpichk ccall((:MPI_Register_datarep_c, libmpi), Cint, (Ptr{Cchar}, Ptr{MPI_Datarep_conversion_function_c}, Ptr{MPI_Datarep_conversion_function_c}, Ptr{MPI_Datarep_extent_function}, MPIPtr), datarep, read_conversion_fn, write_conversion_fn, dtype_file_extent_fn, extra_state)
end

"""
Expand Down
54 changes: 27 additions & 27 deletions src/api/microsoftmpi.jl
Original file line number Diff line number Diff line change
Expand Up @@ -39,26 +39,26 @@ const MPI_Op = Cint
const MPI_Request = Cint
const MPI_Win = Cint

# Function pointers:
const MPI_Comm_copy_attr_function = Ptr{Cvoid}
const MPI_Comm_delete_attr_function = Ptr{Cvoid}
const MPI_Comm_errhandler_function = Ptr{Cvoid}
# Function prototypes:
const MPI_Comm_copy_attr_function = Cvoid
const MPI_Comm_delete_attr_function = Cvoid
const MPI_Comm_errhandler_function = Cvoid
const MPI_Comm_errhandler_fn = MPI_Comm_errhandler_function
const MPI_Copy_function = MPI_Comm_copy_attr_function
const MPI_Datarep_conversion_function = Ptr{Cvoid}
const MPI_Datarep_extent_function = Ptr{Cvoid}
const MPI_Delete_function = Ptr{Cvoid}
const MPI_File_errhandler_function = Ptr{Cvoid}
const MPI_File_errhandler_fn = Ptr{Cvoid}
const MPI_Grequest_cancel_function = Ptr{Cvoid}
const MPI_Grequest_free_function = Ptr{Cvoid}
const MPI_Grequest_query_function = Ptr{Cvoid}
const MPI_Type_copy_attr_function = Ptr{Cvoid}
const MPI_Type_delete_attr_function = Ptr{Cvoid}
const MPI_User_function = Ptr{Cvoid}
const MPI_Win_copy_attr_function = Ptr{Cvoid}
const MPI_Win_delete_attr_function = Ptr{Cvoid}
const MPI_Win_errhandler_function = Ptr{Cvoid}
const MPI_Datarep_conversion_function = Cvoid
const MPI_Datarep_extent_function = Cvoid
const MPI_Delete_function = Cvoid
const MPI_File_errhandler_function = Cvoid
const MPI_File_errhandler_fn = Cvoid
const MPI_Grequest_cancel_function = Cvoid
const MPI_Grequest_free_function = Cvoid
const MPI_Grequest_query_function = Cvoid
const MPI_Type_copy_attr_function = Cvoid
const MPI_Type_delete_attr_function = Cvoid
const MPI_User_function = Cvoid
const MPI_Win_copy_attr_function = Cvoid
const MPI_Win_delete_attr_function = Cvoid
const MPI_Win_errhandler_function = Cvoid
const MPI_Win_errhandler_fn = MPI_Win_errhandler_function


Expand Down Expand Up @@ -227,9 +227,9 @@ const MPI_Win_errhandler_fn = MPI_Win_errhandler_function
@const_ref MPI_COMM_SELF MPI_Comm 0x44000001
@const_ref MPI_COMM_WORLD MPI_Comm 0x44000000

@const_ref MPI_COMM_DUP_FN MPI_Comm_copy_attr_function cglobal((:MPIR_Dup_fn, libmpi), MPI_Comm_copy_attr_function)
@const_ref MPI_COMM_NULL_COPY_FN MPI_Comm_copy_attr_function C_NULL
@const_ref MPI_COMM_NULL_DELETE_FN MPI_Comm_delete_attr_function C_NULL
@const_ref MPI_COMM_DUP_FN Ptr{MPI_Comm_copy_attr_function} cglobal((:MPIR_Dup_fn, libmpi), Ptr{MPI_Comm_copy_attr_function})
@const_ref MPI_COMM_NULL_COPY_FN Ptr{MPI_Comm_copy_attr_function} C_NULL
@const_ref MPI_COMM_NULL_DELETE_FN Ptr{MPI_Comm_delete_attr_function} C_NULL

@const_ref MPI_DATATYPE_NULL MPI_Datatype 0x0c000000

Expand Down Expand Up @@ -323,12 +323,12 @@ const MPI_LONG_LONG = MPI_LONG_LONG_INT
@const_ref MPI_STATUS_IGNORE Ptr{Cvoid} 1
@const_ref MPI_STATUSES_IGNORE Ptr{Cvoid} 1

@const_ref MPI_TYPE_DUP_FN MPI_Comm_copy_attr_function cglobal((:MPIR_Dup_fn, libmpi), MPI_Comm_copy_attr_function)
@const_ref MPI_TYPE_NULL_COPY_FN MPI_Type_copy_attr_function C_NULL
@const_ref MPI_TYPE_NULL_DELETE_FN MPI_Type_delete_attr_function C_NULL
@const_ref MPI_TYPE_DUP_FN Ptr{MPI_Comm_copy_attr_function} cglobal((:MPIR_Dup_fn, libmpi), Ptr{MPI_Comm_copy_attr_function})
@const_ref MPI_TYPE_NULL_COPY_FN Ptr{MPI_Type_copy_attr_function} C_NULL
@const_ref MPI_TYPE_NULL_DELETE_FN Ptr{MPI_Type_delete_attr_function} C_NULL

@const_ref MPI_WIN_NULL MPI_Win 0x20000000

@const_ref MPI_WIN_DUP_FN MPI_Win_copy_attr_function cglobal((:MPIR_Dup_fn, libmpi), MPI_Win_copy_attr_function)
@const_ref MPI_WIN_NULL_COPY_FN MPI_Win_copy_attr_function C_NULL
@const_ref MPI_WIN_NULL_DELETE_FN MPI_Win_delete_attr_function C_NULL
@const_ref MPI_WIN_DUP_FN Ptr{MPI_Win_copy_attr_function} cglobal((:MPIR_Dup_fn, libmpi), Ptr{MPI_Win_copy_attr_function})
@const_ref MPI_WIN_NULL_COPY_FN Ptr{MPI_Win_copy_attr_function} C_NULL
@const_ref MPI_WIN_NULL_DELETE_FN Ptr{MPI_Win_delete_attr_function} C_NULL
54 changes: 27 additions & 27 deletions src/api/mpich.jl
Original file line number Diff line number Diff line change
Expand Up @@ -43,26 +43,26 @@ const MPI_Op = Cint
const MPI_Request = Cint
const MPI_Win = Cint

# Function pointers:
const MPI_Comm_copy_attr_function = Ptr{Cvoid}
const MPI_Comm_delete_attr_function = Ptr{Cvoid}
const MPI_Comm_errhandler_function = Ptr{Cvoid}
# Function prototypes:
const MPI_Comm_copy_attr_function = Cvoid
const MPI_Comm_delete_attr_function = Cvoid
const MPI_Comm_errhandler_function = Cvoid
const MPI_Comm_errhandler_fn = MPI_Comm_errhandler_function
const MPI_Copy_function = MPI_Comm_copy_attr_function
const MPI_Datarep_conversion_function = Ptr{Cvoid}
const MPI_Datarep_extent_function = Ptr{Cvoid}
const MPI_Delete_function = Ptr{Cvoid}
const MPI_File_errhandler_function = Ptr{Cvoid}
const MPI_File_errhandler_fn = Ptr{Cvoid}
const MPI_Grequest_cancel_function = Ptr{Cvoid}
const MPI_Grequest_free_function = Ptr{Cvoid}
const MPI_Grequest_query_function = Ptr{Cvoid}
const MPI_Type_copy_attr_function = Ptr{Cvoid}
const MPI_Type_delete_attr_function = Ptr{Cvoid}
const MPI_User_function = Ptr{Cvoid}
const MPI_Win_copy_attr_function = Ptr{Cvoid}
const MPI_Win_delete_attr_function = Ptr{Cvoid}
const MPI_Win_errhandler_function = Ptr{Cvoid}
const MPI_Datarep_conversion_function = Cvoid
const MPI_Datarep_extent_function = Cvoid
const MPI_Delete_function = Cvoid
const MPI_File_errhandler_function = Cvoid
const MPI_File_errhandler_fn = Cvoid
const MPI_Grequest_cancel_function = Cvoid
const MPI_Grequest_free_function = Cvoid
const MPI_Grequest_query_function = Cvoid
const MPI_Type_copy_attr_function = Cvoid
const MPI_Type_delete_attr_function = Cvoid
const MPI_User_function = Cvoid
const MPI_Win_copy_attr_function = Cvoid
const MPI_Win_delete_attr_function = Cvoid
const MPI_Win_errhandler_function = Cvoid
const MPI_Win_errhandler_fn = MPI_Win_errhandler_function

# Run-time constants
Expand Down Expand Up @@ -233,9 +233,9 @@ const MPI_Win_errhandler_fn = MPI_Win_errhandler_function
@const_ref MPI_COMM_SELF MPI_Comm 0x44000001
@const_ref MPI_COMM_WORLD MPI_Comm 0x44000000

@const_ref MPI_COMM_DUP_FN MPI_Comm_copy_attr_function cglobal((:MPIR_Dup_fn, libmpi), MPI_Comm_copy_attr_function)
@const_ref MPI_COMM_NULL_COPY_FN MPI_Comm_copy_attr_function C_NULL
@const_ref MPI_COMM_NULL_DELETE_FN MPI_Comm_delete_attr_function C_NULL
@const_ref MPI_COMM_DUP_FN Ptr{MPI_Comm_copy_attr_function} cglobal((:MPIR_Dup_fn, libmpi), Ptr{MPI_Comm_copy_attr_function})
@const_ref MPI_COMM_NULL_COPY_FN Ptr{MPI_Comm_copy_attr_function} C_NULL
@const_ref MPI_COMM_NULL_DELETE_FN Ptr{MPI_Comm_delete_attr_function} C_NULL

@const_ref MPI_DATATYPE_NULL MPI_Datatype 0x0c000000

Expand Down Expand Up @@ -330,12 +330,12 @@ const MPI_C_COMPLEX = MPI_C_FLOAT_COMPLEX
@const_ref MPI_STATUS_IGNORE Ptr{Cvoid} 1
@const_ref MPI_STATUSES_IGNORE Ptr{Cvoid} 1

@const_ref MPI_TYPE_DUP_FN MPI_Comm_copy_attr_function cglobal((:MPIR_Dup_fn, libmpi), MPI_Comm_copy_attr_function)
@const_ref MPI_TYPE_NULL_COPY_FN MPI_Type_copy_attr_function C_NULL
@const_ref MPI_TYPE_NULL_DELETE_FN MPI_Type_delete_attr_function C_NULL
@const_ref MPI_TYPE_DUP_FN Ptr{MPI_Comm_copy_attr_function} cglobal((:MPIR_Dup_fn, libmpi), Ptr{MPI_Comm_copy_attr_function})
@const_ref MPI_TYPE_NULL_COPY_FN Ptr{MPI_Type_copy_attr_function} C_NULL
@const_ref MPI_TYPE_NULL_DELETE_FN Ptr{MPI_Type_delete_attr_function} C_NULL

@const_ref MPI_WIN_NULL MPI_Win 0x20000000

@const_ref MPI_WIN_DUP_FN MPI_Win_copy_attr_function cglobal((:MPIR_Dup_fn, libmpi), MPI_Win_copy_attr_function)
@const_ref MPI_WIN_NULL_COPY_FN MPI_Win_copy_attr_function C_NULL
@const_ref MPI_WIN_NULL_DELETE_FN MPI_Win_delete_attr_function C_NULL
@const_ref MPI_WIN_DUP_FN Ptr{MPI_Win_copy_attr_function} cglobal((:MPIR_Dup_fn, libmpi), Ptr{MPI_Win_copy_attr_function})
@const_ref MPI_WIN_NULL_COPY_FN Ptr{MPI_Win_copy_attr_function} C_NULL
@const_ref MPI_WIN_NULL_DELETE_FN Ptr{MPI_Win_delete_attr_function} C_NULL
Loading

0 comments on commit 3a46698

Please sign in to comment.