Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Add new entry in Release_Notes.
[simgrid.git] / src / smpi / bindings / smpi_pmpi_info.cpp
1 /* Copyright (c) 2007-2023. The SimGrid Team. All rights reserved.          */
2
3 /* This program is free software; you can redistribute it and/or modify it
4  * under the terms of the license (GNU LGPL) which comes with this package. */
5
6 #include "private.hpp"
7 #include "smpi_info.hpp"
8 #include "smpi_comm.hpp"
9
10 XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(smpi_pmpi);
11
12 /* PMPI User level calls */
13
14 int PMPI_Info_create( MPI_Info *info){
15   CHECK_NULL(1, MPI_ERR_ARG, info)
16   *info = new simgrid::smpi::Info();
17   return MPI_SUCCESS;
18 }
19
20 int PMPI_Info_set( MPI_Info info, const char *key, const char *value){
21   CHECK_INFO(1, info)
22   CHECK_NULL(2, MPI_ERR_INFO_KEY, key)
23   CHECK_NULL(3, MPI_ERR_INFO_VALUE, value)
24   info->set(key, value);
25   return MPI_SUCCESS;
26 }
27
28 int PMPI_Info_free( MPI_Info *info){
29   CHECK_NULL(1, MPI_ERR_ARG, info)
30   CHECK_INFO(1, *info)
31   (*info)->mark_as_deleted();
32   simgrid::smpi::Info::unref(*info);
33   *info=MPI_INFO_NULL;
34   return MPI_SUCCESS;
35 }
36
37 int PMPI_Info_get(MPI_Info info, const char *key,int valuelen, char *value, int *flag){
38   CHECK_INFO(1, info)
39   if (valuelen <0)
40     return MPI_ERR_ARG;
41   CHECK_NULL(2, MPI_ERR_INFO_KEY, key)
42   CHECK_NULL(3, MPI_ERR_INFO_VALUE, value)
43   CHECK_NULL(4, MPI_ERR_ARG, flag)
44   *flag=false;
45   return info->get(key, valuelen, value, flag);
46 }
47
48 int PMPI_Info_dup(MPI_Info info, MPI_Info *newinfo){
49   CHECK_INFO(1, info)
50   CHECK_NULL(2, MPI_ERR_ARG, newinfo)
51   *newinfo = new simgrid::smpi::Info(info);
52   return MPI_SUCCESS;
53 }
54
55 int PMPI_Info_delete(MPI_Info info, const char *key){
56   CHECK_INFO(1, info)
57   CHECK_NULL(2, MPI_ERR_INFO_KEY, key)
58   return info->remove(key);
59 }
60
61 int PMPI_Info_get_nkeys( MPI_Info info, int *nkeys){
62   CHECK_INFO(1, info)
63   CHECK_NULL(2, MPI_ERR_ARG, nkeys)
64   return info->get_nkeys(nkeys);
65 }
66
67 int PMPI_Info_get_nthkey( MPI_Info info, int n, char *key){
68   CHECK_INFO(1, info)
69   CHECK_NULL(2, MPI_ERR_INFO_KEY, key)
70   if (n<0 || n> MPI_MAX_INFO_KEY)
71     return MPI_ERR_ARG;
72   return info->get_nthkey(n, key);
73 }
74
75 int PMPI_Info_get_valuelen( MPI_Info info, const char *key, int *valuelen, int *flag){
76   *flag=false;
77   CHECK_INFO(1, info)
78   CHECK_NULL(2, MPI_ERR_INFO_KEY, key)
79   CHECK_NULL(2, MPI_ERR_INFO_VALUE, valuelen)
80   return info->get_valuelen(key, valuelen, flag);
81 }
82
83 MPI_Info PMPI_Info_f2c(MPI_Fint info){
84   if(info==-1)
85     return MPI_INFO_NULL;
86   return simgrid::smpi::Info::f2c(info);
87 }
88
89 MPI_Fint PMPI_Info_c2f(MPI_Info info){
90   if(info==MPI_INFO_NULL)
91     return -1;
92   return info->c2f();
93 }