Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Merge branch 'actor-yield' of github.com:Takishipp/simgrid into actor-yield
[simgrid.git] / src / smpi / bindings / smpi_pmpi_info.cpp
1 /* Copyright (c) 2007-2017. 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
9 XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(smpi_pmpi);
10
11 /* PMPI User level calls */
12 extern "C" { // Obviously, the C MPI interface should use the C linkage
13
14 int PMPI_Info_create( MPI_Info *info){
15   if (info == nullptr)
16     return MPI_ERR_ARG;
17   *info = new simgrid::smpi::Info();
18   return MPI_SUCCESS;
19 }
20
21 int PMPI_Info_set( MPI_Info info, char *key, char *value){
22   if (info == nullptr || key == nullptr || value == nullptr)
23     return MPI_ERR_ARG;
24   info->set(key, value);
25   return MPI_SUCCESS;
26 }
27
28 int PMPI_Info_free( MPI_Info *info){
29   if (info == nullptr || *info==nullptr)
30     return MPI_ERR_ARG;
31   simgrid::smpi::Info::unref(*info);
32   *info=MPI_INFO_NULL;
33   return MPI_SUCCESS;
34 }
35
36 int PMPI_Info_get(MPI_Info info,char *key,int valuelen, char *value, int *flag){
37   *flag=false;
38   if (info == nullptr || key == nullptr || valuelen <0)
39     return MPI_ERR_ARG;
40   if (value == nullptr)
41     return MPI_ERR_INFO_VALUE;
42   return info->get(key, valuelen, value, flag);
43 }
44
45 int PMPI_Info_dup(MPI_Info info, MPI_Info *newinfo){
46   if (info == nullptr || newinfo==nullptr)
47     return MPI_ERR_ARG;
48   *newinfo = new simgrid::smpi::Info(info);
49   return MPI_SUCCESS;
50 }
51
52 int PMPI_Info_delete(MPI_Info info, char *key){
53   if (info == nullptr || key==nullptr)
54     return MPI_ERR_ARG;
55   return info->remove(key);
56 }
57
58 int PMPI_Info_get_nkeys( MPI_Info info, int *nkeys){
59   if (info == nullptr || nkeys==nullptr)
60     return MPI_ERR_ARG;
61   return info->get_nkeys(nkeys);
62 }
63
64 int PMPI_Info_get_nthkey( MPI_Info info, int n, char *key){
65   if (info == nullptr || key==nullptr || n<0 || n> MPI_MAX_INFO_KEY)
66     return MPI_ERR_ARG;
67   return info->get_nthkey(n, key);
68 }
69
70 int PMPI_Info_get_valuelen( MPI_Info info, char *key, int *valuelen, int *flag){
71   *flag=false;
72   if (info == nullptr || key == nullptr || valuelen==nullptr)
73     return MPI_ERR_ARG;
74   return info->get_valuelen(key, valuelen, flag);
75 }
76
77 MPI_Info PMPI_Info_f2c(MPI_Fint info){
78   return static_cast<MPI_Info>(simgrid::smpi::Info::f2c(info));
79 }
80
81 MPI_Fint PMPI_Info_c2f(MPI_Info info){
82   return info->c2f();
83 }
84
85 }