utils.jl 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. # StarPU --- Runtime system for heterogeneous multicore architectures.
  2. #
  3. # Copyright (C) 2020 Université de Bordeaux, CNRS (LaBRI UMR 5800), Inria
  4. #
  5. # StarPU is free software; you can redistribute it and/or modify
  6. # it under the terms of the GNU Lesser General Public License as published by
  7. # the Free Software Foundation; either version 2.1 of the License, or (at
  8. # your option) any later version.
  9. #
  10. # StarPU is distributed in the hope that it will be useful, but
  11. # WITHOUT ANY WARRANTY; without even the implied warranty of
  12. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  13. #
  14. # See the GNU Lesser General Public License in COPYING.LGPL for more details.
  15. #
  16. import Base.print
  17. function print_newline(io :: IO, indent = 0, n_lines = 1)
  18. for i in (1 : n_lines)
  19. print(io, "\n")
  20. end
  21. for i in (1 : indent)
  22. print(io, " ")
  23. end
  24. end
  25. starpu_indent_size = 4
  26. function rand_char()
  27. r = rand(UInt) % 62
  28. if (0 <= r < 10)
  29. return '0' + r
  30. elseif (10 <= r < 36)
  31. return 'a' + (r - 10)
  32. else
  33. return 'A' + (r - 36)
  34. end
  35. end
  36. function rand_string(size = 8)
  37. output = ""
  38. for i in (1 : size)
  39. output *= string(rand_char())
  40. end
  41. return output
  42. end
  43. function system(cmd :: String)
  44. ccall((:system, "libc"), Cint, (Cstring,), cmd)
  45. end