disk_unistd.c 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. /* StarPU --- Runtime system for heterogeneous multicore architectures.
  2. *
  3. * Copyright (C) 2013-2021 Université de Bordeaux, CNRS (LaBRI UMR 5800), Inria
  4. * Copyright (C) 2013 Corentin Salingue
  5. *
  6. * StarPU is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU Lesser General Public License as published by
  8. * the Free Software Foundation; either version 2.1 of the License, or (at
  9. * your option) any later version.
  10. *
  11. * StarPU is distributed in the hope that it will be useful, but
  12. * WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  14. *
  15. * See the GNU Lesser General Public License in COPYING.LGPL for more details.
  16. */
  17. #include <fcntl.h>
  18. #include <stdlib.h>
  19. #include <sys/stat.h>
  20. #include <stdint.h>
  21. #include <common/config.h>
  22. #ifdef HAVE_UNISTD_H
  23. #include <unistd.h>
  24. #endif
  25. #include <starpu.h>
  26. #include <core/disk.h>
  27. #include <core/perfmodel/perfmodel.h>
  28. #include <core/disk_ops/unistd/disk_unistd_global.h>
  29. /* ------------------- use UNISTD to write on disk ------------------- */
  30. /* allocation memory on disk */
  31. static void *starpu_unistd_alloc(void *base, size_t size)
  32. {
  33. struct starpu_unistd_global_obj *obj;
  34. _STARPU_MALLOC(obj, sizeof(struct starpu_unistd_global_obj));
  35. /* only flags change between unistd and unistd_o_direct */
  36. obj->flags = O_RDWR | O_BINARY;
  37. return starpu_unistd_global_alloc(obj, base, size);
  38. }
  39. /* open an existing memory on disk */
  40. static void *starpu_unistd_open(void *base, void *pos, size_t size)
  41. {
  42. struct starpu_unistd_global_obj *obj;
  43. _STARPU_MALLOC(obj, sizeof(struct starpu_unistd_global_obj));
  44. /* only flags change between unistd and unistd_o_direct */
  45. obj->flags = O_RDWR | O_BINARY;
  46. return starpu_unistd_global_open(obj, base, pos, size);
  47. }
  48. struct starpu_disk_ops starpu_disk_unistd_ops =
  49. {
  50. .alloc = starpu_unistd_alloc,
  51. .free = starpu_unistd_global_free,
  52. .open = starpu_unistd_open,
  53. .close = starpu_unistd_global_close,
  54. .read = starpu_unistd_global_read,
  55. .write = starpu_unistd_global_write,
  56. .plug = starpu_unistd_global_plug,
  57. .unplug = starpu_unistd_global_unplug,
  58. #ifdef STARPU_UNISTD_USE_COPY
  59. .copy = starpu_unistd_global_copy,
  60. #else
  61. .copy = NULL,
  62. #endif
  63. .bandwidth = get_unistd_global_bandwidth_between_disk_and_main_ram,
  64. #ifdef HAVE_AIO_H
  65. .async_read = starpu_unistd_global_async_read,
  66. .async_write = starpu_unistd_global_async_write,
  67. .async_full_read = starpu_unistd_global_async_full_read,
  68. .async_full_write = starpu_unistd_global_async_full_write,
  69. .wait_request = starpu_unistd_global_wait_request,
  70. .test_request = starpu_unistd_global_test_request,
  71. .free_request = starpu_unistd_global_free_request,
  72. #endif
  73. .full_read = starpu_unistd_global_full_read,
  74. .full_write = starpu_unistd_global_full_write
  75. };