OpenRadioss 2025.1.11
OpenRadioss project
Loading...
Searching...
No Matches
VE_Metis.h File Reference
#include <stddef.h>
#include <libvhcall.h>
#include <libgen.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <metis.h>

Go to the source code of this file.

Macros

#define NECVH_MAX_LIBNAME   2048
#define mumps_abort

Functions

int VE_Metis_setdefaultoptions (int *)
int VE_Metis_nodend (int *, int *, int *, int *, int *, int *, int *)

Macro Definition Documentation

◆ mumps_abort

void mumps_abort
Value:
mumps_abort_

Definition at line 25 of file VE_Metis.h.

◆ NECVH_MAX_LIBNAME

#define NECVH_MAX_LIBNAME   2048

Definition at line 23 of file VE_Metis.h.

Function Documentation

◆ VE_Metis_nodend()

int VE_Metis_nodend ( int * nvtxs,
int * xadj,
int * adjncy,
int * vwgt,
int * options,
int * perm,
int * iperm )

Definition at line 15 of file VE_Metis_nodend.c.

15 {
16 int ret=1;
17 int64_t symid;
18 vhcall_handle handle;
19 vhcall_args *ca;
20 uint64_t retval = -1;
21
22 char * env_metis_lib_name;
23 char metis_lib_name[ NECVH_MAX_LIBNAME ];
24
25 /*
26 * -----------------------------------------------------------------------
27 * Set the library name ( check environment )
28 * -----------------------------------------------------------------------
29 */
30
31 if ( env_metis_lib_name = getenv( "VH_MUMPS_LIBRARY" ) ) {
32 size_t lenv = strlen( env_metis_lib_name );
33 if ( strlen( env_metis_lib_name ) > (size_t)NECVH_MAX_LIBNAME ) {
34 fprintf( stdout , "%s @ %d failed : metis library name too long (%s)\n" , basename(__FILE__) , __LINE__ , env_metis_lib_name );
35 fflush( stdout );
36 (void) mumps_abort();
37 }
38 else {
39 memcpy( ( void * ) metis_lib_name , ( void * ) env_metis_lib_name , lenv * sizeof( char) );
40 metis_lib_name[ lenv ] = '\0';
41 fprintf( stdout , "%s @ %d input library %s\n" , basename(__FILE__) , __LINE__ , metis_lib_name );
42 fflush( stdout );
43 }
44 }
45 else {
46 strcpy( metis_lib_name , "libvh.so" );
47 }
48
49 /*
50 * -----------------------------------------------------------------------
51 * Load VH C library
52 * -----------------------------------------------------------------------
53 */
54
55 handle = vhcall_install( metis_lib_name );
56 if (handle == (vhcall_handle)-1) {
57 perror("vhcall_install");
58 fprintf( stdout , "%s @ %d failed : can't install library %s\n" , basename(__FILE__) , __LINE__ , metis_lib_name );
59 fprintf( stdout , "Please check your LD_LIBRARY_PATH variable\n");
60 fflush( stdout );
61 (void) mumps_abort();
62 }
63
64 /*
65 * -----------------------------------------------------------------------
66 * Find VH C library function
67 * -----------------------------------------------------------------------
68 */
69
70 symid = vhcall_find(handle, "METIS_NodeND");
71 if ( symid == -1 ) {
72 perror("vhcall_find");
73 fprintf( stdout , "%s @ %d failed : can't find symbol METIS_NodeND\n" , basename(__FILE__) , __LINE__ );
74 fflush( stdout );
75 (void) mumps_abort();
76 }
77
78 /*
79 * -----------------------------------------------------------------------
80 * Allocate arguments object for VH library function
81 * -----------------------------------------------------------------------
82 */
83
84 ca = vhcall_args_alloc();
85 if (! ca) {
86 perror("vhcall_args_alloc");
87 fprintf( stdout , "%s @ %d failed : unable to allocate function's argument list\n" , basename(__FILE__) , __LINE__ );
88 fflush( stdout );
89 (void) mumps_abort();
90 }
91
92 /*
93 * -----------------------------------------------------------------------
94 * Set arguments
95 * -----------------------------------------------------------------------
96 */
97
98 ret = vhcall_args_set_pointer( ca , VHCALL_INTENT_IN , 0 , nvtxs , sizeof( idx_t ) );
99 if ( ret ) {
100 perror("vhcall_args_set_pointer");
101 fprintf( stdout , "%s @ %d failed : unable to set argument.\n" , basename(__FILE__) , __LINE__ );
102 fflush( stdout );
103 (void) mumps_abort();
104 }
105
106 ret = vhcall_args_set_pointer( ca , VHCALL_INTENT_IN , 1 , xadj , ( *nvtxs + 1 ) * sizeof( idx_t ) );
107 if ( ret ) {
108 perror("vhcall_args_set_pointer");
109 fprintf( stdout , "%s @ %d failed : unable to set argument.\n" , basename(__FILE__) , __LINE__ );
110 fflush( stdout );
111 (void) mumps_abort();
112 }
113
114 ret = vhcall_args_set_pointer( ca , VHCALL_INTENT_IN , 2 , adjncy , xadj[ *nvtxs ] * sizeof( idx_t ) );
115 if ( ret ) {
116 perror("vhcall_args_set_pointer");
117 fprintf( stdout , "%s @ %d failed : unable to set argument.\n" , basename(__FILE__) , __LINE__ );
118 fflush( stdout );
119 (void) mumps_abort();
120 }
121
122 int len;
123 if ( vwgt )
124 len = *nvtxs;
125 else
126 len = 0;
127
128 ret = vhcall_args_set_pointer( ca , VHCALL_INTENT_IN , 3 , vwgt , len * sizeof( idx_t ) );
129 if ( ret ) {
130 perror("vhcall_args_set_pointer");
131 fprintf( stdout , "%s @ %d failed : unable to set argument.\n" , basename(__FILE__) , __LINE__ );
132 fflush( stdout );
133 (void) mumps_abort();
134 }
135
136 ret = vhcall_args_set_pointer( ca , VHCALL_INTENT_IN , 4 , options , METIS_NOPTIONS * sizeof( idx_t ) );
137 if ( ret ) {
138 perror("vhcall_args_set_pointer");
139 fprintf( stdout , "%s @ %d failed : unable to set argument.\n" , basename(__FILE__) , __LINE__ );
140 fflush( stdout );
141 (void) mumps_abort();
142 }
143
144 ret = vhcall_args_set_pointer( ca , VHCALL_INTENT_OUT , 5 , perm , *nvtxs * sizeof( idx_t ) );
145 if ( ret ) {
146 perror("vhcall_args_set_pointer");
147 fprintf( stdout , "%s @ %d failed : unable to set argument.\n" , basename(__FILE__) , __LINE__ );
148 fflush( stdout );
149 (void) mumps_abort();
150 }
151
152 ret = vhcall_args_set_pointer( ca , VHCALL_INTENT_OUT , 6 , iperm , *nvtxs * sizeof( idx_t ) );
153 if ( ret ) {
154 perror("vhcall_args_set_pointer");
155 fprintf( stdout , "%s @ %d failed : unable to set argument.\n" , basename(__FILE__) , __LINE__ );
156 fflush( stdout );
157 (void) mumps_abort();
158 }
159
160 /*
161 * -----------------------------------------------------------------------
162 * Invoke VH C library function
163 * -----------------------------------------------------------------------
164 */
165
166 ret = vhcall_invoke_with_args( symid , ca , &retval );
167 if ( ret ) {
168 perror("vhcall_invoke_with_args");
169 fprintf( stdout , "%s @ %d failed : unable to invoke the symbol from library\n" , basename(__FILE__) , __LINE__ );
170 fflush( stdout );
171 (void) mumps_abort();
172 }
173
174 /*
175 * -----------------------------------------------------------------------
176 * Free args
177 * -----------------------------------------------------------------------
178 */
179
180 vhcall_args_free( ca );
181
182 /*
183 * -----------------------------------------------------------------------
184 * Uninstall the library
185 * -----------------------------------------------------------------------
186 */
187
188 if ( vhcall_uninstall( handle ) ) {
189 perror("vhcall_uninstall");
190 fprintf( stdout , "%s @ %d failed : unable to uninstall the library\n" , basename(__FILE__) , __LINE__ );
191 fflush( stdout );
192 (void) mumps_abort();
193 }
194
195 return( (int) retval );
196}
#define mumps_abort
Definition VE_Metis.h:25
#define NECVH_MAX_LIBNAME
Definition VE_Metis.h:23
void * handle

◆ VE_Metis_setdefaultoptions()

int VE_Metis_setdefaultoptions ( int * options)

Definition at line 15 of file VE_Metis_setdefaultoptions.c.

15 {
16 int ret=1;
17 int64_t symid;
18 vhcall_handle handle;
19 vhcall_args *ca;
20 uint64_t retval = -1;
21
22 char * env_metis_lib_name;
23 char metis_lib_name[ NECVH_MAX_LIBNAME ];
24
25 /*
26 * -----------------------------------------------------------------------
27 * Set the library name ( check environment )
28 * -----------------------------------------------------------------------
29 */
30
31 if ( env_metis_lib_name = getenv( "VH_MUMPS_LIBRARY" ) ) {
32 size_t lenv = strlen( env_metis_lib_name );
33 if ( strlen( env_metis_lib_name ) > (size_t)NECVH_MAX_LIBNAME ) {
34 fprintf( stdout , "%s @ %d failed : metis library name too long (%s)\n" , basename(__FILE__) , __LINE__ , env_metis_lib_name );
35 fflush( stdout );
36 (void) mumps_abort();
37 }
38 else {
39 memcpy( ( void * ) metis_lib_name , ( void * ) env_metis_lib_name , lenv * sizeof( char) );
40 metis_lib_name[ lenv ] = '\0';
41 fprintf( stdout , "%s @ %d input library %s\n" , basename(__FILE__) , __LINE__ , metis_lib_name );
42 fflush( stdout );
43 }
44 }
45 else {
46 strcpy( metis_lib_name , "libvh.so" );
47 }
48
49 /*
50 * -----------------------------------------------------------------------
51 * Load VH C library
52 * -----------------------------------------------------------------------
53 */
54
55 handle = vhcall_install( metis_lib_name );
56 if (handle == (vhcall_handle)-1) {
57 perror("vhcall_install");
58 fprintf( stdout , "%s @ %d failed : can't install library %s\n" , basename(__FILE__) , __LINE__ , metis_lib_name );
59 fprintf( stdout , "Please check your LD_LIBRARY_PATH variable\n");
60 fflush( stdout );
61 (void) mumps_abort();
62 }
63
64 /*
65 * -----------------------------------------------------------------------
66 * Find VH C library function
67 * -----------------------------------------------------------------------
68 */
69
70 symid = vhcall_find(handle, "METIS_SetDefaultOptions");
71 if ( symid == -1 ) {
72 fprintf( stdout , "%s @ %d failed : can't find symbol METIS_SetDefaultOptions\n" , basename(__FILE__) , __LINE__ );
73 perror("vhcall_find");
74 fflush( stdout );
75 (void) mumps_abort();
76 }
77
78 /*
79 * -----------------------------------------------------------------------
80 * Allocate arguments object for VH library function
81 * -----------------------------------------------------------------------
82 */
83
84 ca = vhcall_args_alloc();
85 if ( ! ca ) {
86 perror("vhcall_args_alloc");
87 fprintf( stdout , "%s @ %d failed : unable to allocate function's argument list\n" , basename(__FILE__) , __LINE__ );
88 fflush( stdout );
89 (void) mumps_abort();
90 }
91
92 /*
93 * -----------------------------------------------------------------------
94 * Set argument
95 * -----------------------------------------------------------------------
96 */
97
98 ret = vhcall_args_set_pointer( ca , VHCALL_INTENT_INOUT , 0 , options , METIS_NOPTIONS * sizeof( idx_t ) );
99 if ( ret ) {
100 perror("vhcall_args_set_pointer");
101 fprintf( stdout , "%s @ %d failed : unable to set argument.\n" , basename(__FILE__) , __LINE__ );
102 fflush( stdout );
103 (void) mumps_abort();
104 }
105
106 /*
107 * -----------------------------------------------------------------------
108 * Invoke VH C library function
109 * -----------------------------------------------------------------------
110 */
111
112 ret = vhcall_invoke_with_args( symid , ca , &retval );
113 if ( ret ) {
114 perror("vhcall_invoke_with_args");
115 fprintf( stdout , "%s @ %d failed : unable to invoke the symbol from library\n" , basename(__FILE__) , __LINE__ );
116 fflush( stdout );
117 (void) mumps_abort();
118 }
119
120 /*
121 * -----------------------------------------------------------------------
122 * Free args
123 * -----------------------------------------------------------------------
124 */
125
126 vhcall_args_free( ca );
127
128 /*
129 * -----------------------------------------------------------------------
130 * Uninstall the library
131 * -----------------------------------------------------------------------
132 */
133
134 if ( vhcall_uninstall( handle ) ) {
135 perror("vhcall_uninstall");
136 fprintf( stdout , "cvhmetis_nodend failed : unable to uninstall the library\n" , basename(__FILE__) , __LINE__ );
137 fflush( stdout );
138 (void) mumps_abort();
139 }
140
141 return( (int) retval );
142}