Molssi Driver Interface Library: /repo/build/MDI_Library/MDI_Library/mdi_lib.h Source File

|  | Molssi Driver Interface Library

mdi_lib.h
Go to the documentation of this file.
1
6 #ifndef MDI_LIBRARY_IMPL
7 #define MDI_LIBRARY_IMPL
8
9 #include "mdi.h"
10 #include "mdi_global.h"
11
12 typedef int (*MDI_Plugin_init_t)( void* shared_state );
13
14 /*
15 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
16 !!!!!!!!!!!!!!!!! ABI WARNING !!!!!!!!!!!!!!!!!!!!
17 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
18
19 Changing this structure will affect the plugin ABI
20
21 */
22 typedef struct plugin_shared_state_struct {
25 char command[MDI_COMMAND_LENGTH_];
27 void** ext;
29 int driver_version[3];
31 int engine_version[3];
33 void* buf;
35 char** plugin_argv;
37 char* plugin_options;
39 char* plugin_unedited_options;
41 void* mpi_comm_ptr;
43 void* driver_callback_obj;
45 void* execute_command_obj;
48 void* python_interpreter_dict;
50 void* driver_codes_ptr;
52 void* engine_codes_ptr;
54 void* engine_nodes;
56 int (*driver_activate_code)(void*, int);
58 int (*engine_activate_code)(void*, int);
60 int (*lib_execute_command)(MDI_Comm);
62 int (*execute_command_wrapper)(const char*, MDI_Comm_Type, void*);
64 int (*execute_builtin)(const char*, MDI_Comm_Type, int*);
66 int (*delete_engine)(size_t);
68 size_t engine_code_id;
70 size_t driver_code_id;
72 MDI_execute_command_type execute_command;
74 MDI_Driver_node_callback_t driver_node_callback;
76 MDI_Comm driver_mdi_comm;
78 MDI_Comm engine_mdi_comm;
80 int buf_allocated;
82 int plugin_argc;
84 int plugin_argv_allocated;
86 int intra_rank;
88 int engine_language;
90 int python_interpreter_initialized;
91 } plugin_shared_state;
92
93 typedef struct library_data_struct {
95 plugin_shared_state* shared_state;
97 int connected_code;
99 int execute_on_send;
101 MPI_Comm mpi_comm;
103 void* driver_callback_obj;
105 MDI_Driver_node_callback_t driver_node_callback;
106 #ifdef _WIN32
107
108 HINSTANCE plugin_handle;
109 #else
110
111 void* plugin_handle;
112 #endif
113
114 MDI_Plugin_init_t plugin_init;
116 int is_python;
117 } library_data;
118
119 int enable_plug_support(int code_id);
120 int plug_on_selection();
121 int plug_on_accept_communicator();
122 int plug_on_send_command(const char* command, MDI_Comm comm, int* skip_flag);
123 int plug_after_send_command(const char* command, MDI_Comm comm);
124 int plug_on_recv_command(MDI_Comm comm);
125
126 int library_load_init(const char* plugin_name, void* mpi_comm_ptr,
127 library_data* libd, int mode);
128 int library_parse_options(const char* options, library_data* libd);
129 int library_launch_plugin(const char* plugin_name, const char* options, void* mpi_comm_ptr,
130 MDI_Driver_node_callback_t driver_node_callback,
131 void* driver_callback_object);
132 int library_open_plugin(const char* plugin_name, const char* options, void* mpi_comm_ptr,
133 MDI_Comm* mdi_comm_ptr);
134 int library_close_plugin(MDI_Comm mdi_comm);
135 int library_initialize();
136 int library_set_driver_current(MDI_Comm comm);
137 int library_set_command(const char* command, MDI_Comm comm);
138 int library_execute_command(MDI_Comm comm);
139 int library_send(const void* buf, int count, MDI_Datatype datatype, MDI_Comm comm, int msg_flag);
140 int library_recv(void* buf, int count, MDI_Datatype datatype, MDI_Comm comm, int msg_flag);
141 int library_send_msg(const void* buf, int count, MDI_Datatype datatype, MDI_Comm comm);
142 int library_recv_msg(void* buf, int count, MDI_Datatype datatype, MDI_Comm comm);
143
144 int library_set_state(void* state);
145 int library_activate_code(void* codes_in, int code_id);
146 int library_activate_driver(library_data* libd);
147 int library_activate_engine(library_data* libd);
148
149 int communicator_delete_lib(void* comm);
150 int library_delete_engine(size_t code_id);
151
152 #endif
library_data_struct::driver_node_callback
MDI_Driver_node_callback_t driver_node_callback
Function pointer to the driver node's callback function.
Definition: mdi_lib.h:105
plugin_shared_state_struct::lib_execute_command
int(* lib_execute_command)(MDI_Comm)
Function pointer to the library execute command function.
Definition: mdi_lib.h:60
plugin_shared_state_struct::engine_mdi_comm
MDI_Comm engine_mdi_comm
Engine-side MDI communicator.
Definition: mdi_lib.h:78
plugin_shared_state_struct::execute_command_obj
void * execute_command_obj
Pointer to the class object that is passed to any call to execute_command.
Definition: mdi_lib.h:45
plugin_shared_state_struct::plugin_argc
int plugin_argc
Argument count for plugin command-line options.
Definition: mdi_lib.h:82
library_set_command
int library_set_command(const char *command, MDI_Comm comm)
Set the next command that will be executed through the library communicator.
Definition: mdi_lib.c:971
plugin_shared_state_struct::driver_mdi_comm
MDI_Comm driver_mdi_comm
Driver-side MDI communicator.
Definition: mdi_lib.h:76
plugin_shared_state_struct::delete_engine
int(* delete_engine)(size_t)
Function pointer to the engine's function to delete everything.
Definition: mdi_lib.h:66
plugin_shared_state_struct::buf
void * buf
Buffer used for communication of data.
Definition: mdi_lib.h:33
plug_on_send_command
int plug_on_send_command(const char *command, MDI_Comm comm, int *skip_flag)
Callback when the PLUG method must send a command.
Definition: mdi_lib.c:111
library_delete_engine
int library_delete_engine(size_t code_id)
Function to delete all of the engine's state.
Definition: mdi_lib.c:1403
library_execute_command
int library_execute_command(MDI_Comm comm)
Execute a command through a communicator.
Definition: mdi_lib.c:1013
plugin_shared_state_struct::driver_code_id
size_t driver_code_id
Driver-side ID of the driver code.
Definition: mdi_lib.h:70
library_set_driver_current
int library_set_driver_current(MDI_Comm comm)
Set the driver as the current code.
Definition: mdi_lib.c:930
library_data_struct::connected_code
int connected_code
Handle of the code to which this communicator connects.
Definition: mdi_lib.h:97
plugin_shared_state_struct::driver_node_callback
MDI_Driver_node_callback_t driver_node_callback
Function pointer to the driver node's callback function.
Definition: mdi_lib.h:74
mdi_global.h
Global structures used by MDI.
plugin_shared_state_struct::python_interpreter_initialized
int python_interpreter_initialized
Flag whether the Python interpreter has been initialized.
Definition: mdi_lib.h:90
library_send
int library_send(const void *buf, int count, MDI_Datatype datatype, MDI_Comm comm, int msg_flag)
Function to handle sending data through an MDI connection, using library-based communication.
Definition: mdi_lib.c:1074
plug_on_selection
int plug_on_selection()
Callback when the end-user selects PLUG as the method.
Definition: mdi_lib.c:50
plugin_shared_state_struct::driver_callback_obj
void * driver_callback_obj
Pointer to the class object that is used for the driver_node_callback function.
Definition: mdi_lib.h:43
plugin_shared_state_struct::command
char command[MDI_COMMAND_LENGTH_]
Name of the next command to be executed on this code. This is only used by engines.
Definition: mdi_lib.h:25
plugin_shared_state_struct::engine_nodes
void * engine_nodes
Pointer to the engine's nodes vector.
Definition: mdi_lib.h:54
communicator_delete_lib
int communicator_delete_lib(void *comm)
Function for LIBRARY-specific deletion operations for communicator deletion.
Definition: mdi_lib.c:1308
plugin_shared_state_struct::execute_command
MDI_execute_command_type execute_command
Pointer to engine's execute_command function.
Definition: mdi_lib.h:72
plugin_shared_state_struct::buf_allocated
int buf_allocated
Flag whether buf is allocated.
Definition: mdi_lib.h:80
plugin_shared_state_struct
Definition: mdi_lib.h:22
plugin_shared_state_struct::plugin_unedited_options
char * plugin_unedited_options
Unedited command-line options for currently running plugin.
Definition: mdi_lib.h:39
plug_on_recv_command
int plug_on_recv_command(MDI_Comm comm)
Callback when the PLUG method must receive a command.
Definition: mdi_lib.c:222
library_data_struct::is_python
int is_python
Flag whether this communicator connects to a Python library.
Definition: mdi_lib.h:116
plugin_shared_state_struct::engine_version
int engine_version[3]
Version number of the engine.
Definition: mdi_lib.h:31
library_launch_plugin
int library_launch_plugin(const char *plugin_name, const char *options, void *mpi_comm_ptr, MDI_Driver_node_callback_t driver_node_callback, void *driver_callback_object)
Launch an MDI plugin.
Definition: mdi_lib.c:512
plugin_shared_state_struct::execute_builtin
int(* execute_builtin)(const char *, MDI_Comm_Type, int *)
Function pointer to the engine's function for responding to built-in commands.
Definition: mdi_lib.h:64
plugin_shared_state_struct::engine_code_id
size_t engine_code_id
Engine-side ID of the engine code.
Definition: mdi_lib.h:68
library_open_plugin
int library_open_plugin(const char *plugin_name, const char *options, void *mpi_comm_ptr, MDI_Comm *mdi_comm_ptr)
Open an MDI plugin in the background.
Definition: mdi_lib.c:664
plugin_shared_state_struct::driver_activate_code
int(* driver_activate_code)(void *, int)
Function pointer to the driver's library_activate_code function.
Definition: mdi_lib.h:56
library_data_struct::plugin_init
MDI_Plugin_init_t plugin_init
Initialization function for the plugin library.
Definition: mdi_lib.h:114
plugin_shared_state_struct::ext
void ** ext
For future-proofing, this is a pointer to any extensions to this structure.
Definition: mdi_lib.h:27
plugin_shared_state_struct::python_interpreter_dict
void * python_interpreter_dict
Pointer to the original Python interpreter's dictionary. Only used for Python plugins.
Definition: mdi_lib.h:48
enable_plug_support
int enable_plug_support(int code_id)
Enable support for the PLUG method.
Definition: mdi_lib.c:25
plugin_shared_state_struct::engine_language
int engine_language
Flag whether the engine is a Python code.
Definition: mdi_lib.h:88
plugin_shared_state_struct::plugin_argv_allocated
int plugin_argv_allocated
Flag whether plugin_argv is allocted for this code.
Definition: mdi_lib.h:84
plugin_shared_state_struct::plugin_options
char * plugin_options
Command-line options for currently running plugin.
Definition: mdi_lib.h:37
plugin_shared_state_struct::plugin_argv
char ** plugin_argv
Argument vector for plugin command-line options.
Definition: mdi_lib.h:35
plugin_shared_state_struct::engine_activate_code
int(* engine_activate_code)(void *, int)
Function pointer to the engine's library_activate_code function.
Definition: mdi_lib.h:58
library_load_init
int library_load_init(const char *plugin_name, void *mpi_comm_ptr, library_data *libd, int mode)
Load the initialization function for a plugin.
Definition: mdi_lib.c:287
library_data_struct::shared_state
plugin_shared_state * shared_state
State shared between the driver and the plugin.
Definition: mdi_lib.h:95
plugin_shared_state_struct::engine_codes_ptr
void * engine_codes_ptr
Pointer to the engine's codes vector.
Definition: mdi_lib.h:52
library_activate_code
int library_activate_code(void *codes_in, int code_id)
Function to set the active code.
Definition: mdi_lib.c:1454
plug_on_accept_communicator
int plug_on_accept_communicator()
Callback when the PLUG method must accept a communicator.
Definition: mdi_lib.c:72
plugin_shared_state_struct::driver_codes_ptr
void * driver_codes_ptr
Pointer to the driver's codes vector.
Definition: mdi_lib.h:50
library_recv
int library_recv(void *buf, int count, MDI_Datatype datatype, MDI_Comm comm, int msg_flag)
Function to handle receiving data through an MDI connection, using library-based communication.
Definition: mdi_lib.c:1214
plugin_shared_state_struct::execute_command_wrapper
int(* execute_command_wrapper)(const char *, MDI_Comm_Type, void *)
Function pointer to a wrapper for the language-specific execute command function.
Definition: mdi_lib.h:62
plugin_shared_state_struct::intra_rank
int intra_rank
MPI rank of this process within the plugin
Definition: mdi_lib.h:86
library_data_struct::mpi_comm
MPI_Comm mpi_comm
MPI intra-communicator for the engine.
Definition: mdi_lib.h:101
plugin_shared_state_struct::mpi_comm_ptr
void * mpi_comm_ptr
Pointer to the intra-communicator for the plugin.
Definition: mdi_lib.h:41
library_data_struct::execute_on_send
int execute_on_send
Flag whether the next MDI_Send call should trigger execution of the engine's command.
Definition: mdi_lib.h:99
library_initialize
int library_initialize()
Perform initialization of a communicator for library-based communication.
Definition: mdi_lib.c:826
library_data_struct::plugin_handle
void * plugin_handle
Non-windows handle for the plugin library.
Definition: mdi_lib.h:111
library_data_struct
Definition: mdi_lib.h:93
library_set_state
int library_set_state(void *state)
Function to set the plugin's state.
Definition: mdi_lib.c:1424
plugin_shared_state_struct::driver_version
int driver_version[3]
Version number of the driver.
Definition: mdi_lib.h:29
library_data_struct::driver_callback_obj
void * driver_callback_obj
Pointer to the class object that is used for the driver_node_callback function.
Definition: mdi_lib.h:103
plug_after_send_command
int plug_after_send_command(const char *command, MDI_Comm comm)
Callback after the PLUG method has received a command.
Definition: mdi_lib.c:215
library_parse_options
int library_parse_options(const char *options, library_data *libd)
Parse command-line plugin options.
Definition: mdi_lib.c:418