1 /*
2  *  pvm_functions.h
3  *
4  *  Copyright (C) Marzio Malanchini - July 2003
5  *
6  *  This file is part of transcode, a video stream processing tool
7  *
8  *  transcode is free software; you can redistribute it and/or modify
9  *  it under the terms of the GNU General Public License as published by
10  *  the Free Software Foundation; either version 2, or (at your option)
11  *  any later version.
12  *
13  *  transcode is distributed in the hope that it will be useful,
14  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
15  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16  *  GNU General Public License for more details.
17  *
18  *  You should have received a copy of the GNU General Public License
19  *  along with GNU Make; see the file COPYING.  If not, write to
20  *  the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
21  *
22  */
23 
24 #ifndef _PVM_FUNCTIONS_H
25 #define _PVM_FUNCTIONS_H
26 
27 #include <stdio.h>
28 #include <pvm3.h>
29 #include <pvm_version.h>
30 
31 
32 typedef struct _pvm_res_func_t 	{
33 					int 	s_rc;
34 					int 	s_ret_size;
35 					int 	s_msg_type;
36 					int 	s_dim_buffer;
37 					char 	*p_result;
38 				} pvm_res_func_t;
39 
40 
41 typedef struct _pvm_func_t 	{
42 					int 	s_nproc;
43 					int 	s_nhosts;
44 					int	s_current_tid;
45 					int 	*p_slave_tids;
46 					int 	*p_used_tid;
47 				} pvm_func_t;
48 
49 #define PVM_EXP_OPT_INIT		0x00000000
50 #define PVM_EXP_OPT_OPEN		0x00000001
51 #define PVM_EXP_OPT_ENCODE		0x00000002
52 #define PVM_EXP_OPT_CLOSE 		0x00000003
53 #define PVM_EXP_OPT_STOP		0x00000004
54 #define PVM_EXP_OPT_RESTART_ENCODE1   	0x00000005
55 #define PVM_JOIN_OPT_RUN 	  	0x00000006
56 #define PVM_JOIN_OPT_ADD_ELAB 	  	0x00000007
57 #define PVM_JOIN_OPT_ADD_REMOVE	  	0x00000008
58 #define PVM_JOIN_OPT_INIT	  	0x00000009
59 #define PVM_INIT_SKED   		0x0000000A
60 #define PVM_INIT_JOIN   		0x0000000B
61 #define PVM_CHECK_VERSION   		0x0000000C
62 #define PVM_JOIN_OPT_SENDFILE  		0x0000000D
63 #define PVM_MERGER_INIT  		0x0000000E
64 #define PVM_EXP_OPT_PREINIT		0x0000000F
65 #define PVM_EXP_OPT_RESTART_ENCODE2   	0x00000010
66 
67 #define PVM_MSG_WORK 			0x00000020
68 #define PVM_MSG_RING 			0x00000021
69 #define PVM_MSG_CONF 			0x00000022
70 #define PVM_MSG_WRKN 			0x00000023
71 #define PVM_MSG_JOIN	   		0x00000024
72 #define PVM_MSG_CONF_JOIN		0x00000025
73 #define PVM_MSG_MERG_SEND		0x00000026
74 #define PVM_MSG_MERG_PASTE		0x00000027
75 #define PVM_MSG_ADD_REM			0x00000028
76 #define PVM_MSG_ENDTASK_SYSTEM 		INT_MAX-2
77 #define PVM_MSG_ENDTASK_VIDEO 		INT_MAX-1
78 #define PVM_MSG_ENDTASK_AUDIO 		INT_MAX
79 #define PVM_MSG_LAST_SEQ		PVM_MSG_ENDTASK_SYSTEM
80 
81 #ifdef PVM_DL_FUNC
82 
83 /*public function*/
84 pvm_func_t * (*f_pvm_master_start_stop)(char *p_option,char *p_spawn_process,char **p_argv,int s_nproc_host,int s_nproc_max,pvm_func_t *p_func);
85 void (*f_pvm_skeduler)(pvm_res_func_t *(*f_my_elab_func)(int,char *,int,int));
86 int (*f_pvm_send)(int s_buff_size,char *p_buffer,int s_option,int s_pos_tids,pvm_func_t *p_func);
87 int (*f_pvm_set_send)(int s_set_seq);
88 int (*f_pvm_multi_send)(int s_buff_size,char *p_buffer,int s_option,pvm_func_t *p_func);
89 int (*f_pvm_multi_send_nw)(int s_buff_size,char *p_buffer,int s_option,pvm_func_t *p_func);
90 int (*f_pvm_nrecv)(int *s_buff_size,char *p_buffer,int *s_rc);
91 int (*f_pvm_recv)(int *s_buff_size,char *p_buffer,int *s_rc);
92 int (*f_pvm_set_nrecv)(int s_seq);
93 int (*f_pvm_set_recv)(int s_seq);
94 int (*f_pvm_start_single_process)(char *p_spawn_process,char **p_argv,char *p_where);
95 void (*f_pvm_stop_single_process)(int p_slave_tid);
96 #else
97 
98 /*private function*/
99 
100 /* f_pvm_master_start_stop:
101 	s_type:			1 start 0 end
102 	p_spawn_process: 	process to spawn
103 	s_nproc_host: 		number of process per host
104 	s_nproc_max: 		max number of process
105 */
106 pvm_func_t *f_pvm_master_start_stop(char *p_option,char *p_spawn_process,char **p_argv,int s_nproc_host,int s_nproc_max,pvm_func_t *p_func);
107 /* the skeduler require a function to elab the input data*/
108 void f_pvm_skeduler(pvm_res_func_t *(*f_my_elab_func)(int,char *,int,int));
109 int f_pvm_send(int s_buff_size,char *p_buffer,int s_option,int s_pos_tids,pvm_func_t *p_func);
110 int f_pvm_set_send(int s_set_seq);
111 int f_pvm_multi_send(int s_buff_size,char *p_buffer,int s_option,pvm_func_t *p_func);/*broadcast the info and wait for the completition of all the task*/
112 int f_pvm_multi_send_nw(int s_buff_size,char *p_buffer,int s_option,pvm_func_t *p_func);/*broadcast the info*/
113 /* If you start with a non blocking receive you must continue with the save api or set the seq number with the set api*/
114 int f_pvm_nrecv(int *s_buff_size,char *p_buffer,int *s_rc);
115 int f_pvm_recv(int *s_buff_size,char *p_buffer,int *s_rc);
116 int f_pvm_set_nrecv(int s_seq);
117 int f_pvm_set_recv(int s_seq);
118 int f_ring(int s_father_tid,int *s_rec_seq,int s_msg_type,int s_rc);
119 int f_pvm_start_single_process(char *p_spawn_process,char **p_argv,char *p_where);
120 void f_pvm_stop_single_process(int p_slave_tid);
121 
122 
123 #endif
124 
125 #endif
126