Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
4cfbe05a879396180dc07111e00d62b46588d39c
[simgrid.git] / src / smpi / mpi / smpi_file.cpp
1 /* Copyright (c) 2007-2019. The SimGrid Team. All rights reserved.          */\r
2 \r
3 /* This program is free software; you can redistribute it and/or modify it\r
4  * under the terms of the license (GNU LGPL) which comes with this package. */\r
5 #include "private.hpp"\r
6 \r
7 #include "smpi_comm.hpp"\r
8 #include "smpi_coll.hpp"\r
9 #include "smpi_info.hpp"\r
10 #include "smpi_file.hpp"\r
11 #include "simgrid/plugins/file_system.h"\r
12 \r
13 \r
14 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(smpi_io, smpi, "Logging specific to SMPI (RMA operations)");\r
15 \r
16 \r
17 namespace simgrid{\r
18 namespace smpi{\r
19   File::File(MPI_Comm comm, char *filename, int amode, MPI_Info info): comm_(comm), flags_(amode), info_(info){\r
20     file_= new simgrid::s4u::File(filename, nullptr);\r
21   }\r
22   \r
23   File::~File(){\r
24     delete file_;\r
25   }\r
26   \r
27   int File::close(MPI_File *fh){\r
28     (*fh)->sync();\r
29     if((*fh)->flags() & MPI_MODE_DELETE_ON_CLOSE)\r
30       (*fh)->file_->unlink();\r
31     delete fh;\r
32     return MPI_SUCCESS;\r
33   }\r
34   \r
35   int File::del(char *filename, MPI_Info info){\r
36     File* f = new File(MPI_COMM_SELF,filename,MPI_MODE_DELETE_ON_CLOSE|MPI_MODE_RDWR, nullptr);\r
37     close(&f);\r
38     return MPI_SUCCESS;\r
39   }\r
40   \r
41   int File::size(){\r
42     return file_->size();\r
43   }\r
44   \r
45   int File::flags(){\r
46     return flags_;\r
47   }\r
48   int File::sync(){\r
49     //no idea\r
50     return simgrid::smpi::Colls::barrier(comm_);\r
51   }\r
52 }\r
53 }