1 /*
2 * Copyright © 2016 Inria. All rights reserved.
3 *
4 * $COPYRIGHT$
5 *
6 * Additional copyrights may follow
7 * See COPYING in top-level directory.
8 *
9 * $HEADER$
10 */
11
12 #ifndef _NETLOCSCOTCH_H_
13 #define _NETLOCSCOTCH_H_
14
15 #ifndef _GNU_SOURCE
16 #define _GNU_SOURCE // for asprintf
17 #endif
18
19 #include <hwloc/autogen/config.h>
20 #include <netloc.h>
21
22 /* Includes for Scotch */
23 #include <stdio.h>
24 #include <scotch.h>
25
26 #ifdef __cplusplus
27 extern "C" {
28 #endif
29
30 /**
31 * A structure to represent process mapping
32 */
33 typedef struct {
34 int rank; /**< Rank of the process */
35 char *nodename; /**< Name of the node */
36 int core; /**< Physical slot number of the core */
37 } netlocscotch_core_t;
38
39 /**
40 * \brief Build the Scotch architecture representing the all machine
41 *
42 * \param arch Pointer to the Scotch arch that will be built.
43 *
44 * \returns 0 on success
45 * \returns NETLOC_ERROR on error
46 */
47 int netlocscotch_build_global_arch(SCOTCH_Arch *arch);
48
49 /**
50 * \brief Build the Scotch architecture representing the available resources
51 *
52 * This function reads the file about available resources, found by reading the
53 * environment variable NETLOC_CURRENTSLOTS. The file must be generated before
54 * calling the program running this functions with: mpirun -np <nprocs>
55 * netloc_mpi_find_hosts <outputfile>
56 * The complete architecture is needed since the sub architecture use data from it.
57 *
58 * \param arch Pointer to the Scotch arch that will be built.
59 * \param subarch Pointer to the Scotch sub arch that will be built.
60 *
61 * \returns 0 on success
62 * \returns NETLOC_ERROR on error
63 */
64 int netlocscotch_build_current_arch(SCOTCH_Arch *arch, SCOTCH_Arch *subarch);
65
66 /**
67 * \brief Give a good mapping with Scotch from a file containing a
68 * communication matrix
69 *
70 * This function reads the file about available resources, found by reading the
71 * environment variable NETLOC_CURRENTSLOTS. The file must be generated before
72 * calling the program running this functions with: mpirun -np <nprocs>
73 * netloc_mpi_find_hosts <outputfile>
74 *
75 * An application graph is built from the communication matrix and is mapped to
76 * the architecture graph built from the resource file.
77 *
78 * \param[in] filename Filename of the matrix file, where the matrix is stored line
79 * by line with spaces between values.
80 *
81 * \param[out] pnum_processes Pointer to the integer where th number of processes
82 * will be written.
83 *
84 * \param[out] pcores Array of pnum_processes elements.
85 *
86 * \returns 0 on succes
87 * \returns NETLOC_ERROR on error
88 */
89 int netlocscotch_get_mapping_from_comm_file(char *filename, int *pnum_processes,
90 netlocscotch_core_t **pcores);
91
92 /**
93 * \brief Give a good mapping with Scotch from a communication matrix
94 *
95 * This function reads the file about available resources, found by reading the
96 * environment variable NETLOC_CURRENTSLOTS. The file must be generated before
97 * calling the program running this functions with: mpirun -np <nprocs>
98 * netloc_mpi_find_hosts <outputfile>
99 *
100 * An application graph is built from the communication matrix and is mapped to
101 * the architecture graph built from the resource file.
102 *
103 * \param[in] comm pointer to the lines of the matrix of communications.
104 *
105 * \param[in] num_vertices number of processes, that corresponds to the size of
106 * the matrix.
107 *
108 * \param[out] pcores Array of num_vertices elements.
109 *
110 * \returns 0 on success
111 * \returns NETLOC_ERROR on error
112 */
113 int netlocscotch_get_mapping_from_comm_matrix(double **comm, int num_vertices,
114 netlocscotch_core_t **pcores);
115
116 #ifdef __cplusplus
117 } /* extern "C" */
118 #endif
119
120 /** @} */
121
122 #endif // _NETLOC_H_