项目作者: agforero

项目描述 :
A collection of Python and Bash scripts to enable easy testing of Fortran compilers using BATS.
高级语言: Fortran
项目地址: git://github.com/agforero/FTFramework.git
创建时间: 2020-06-25T21:59:26Z
项目社区:https://github.com/agforero/FTFramework

开源协议:MIT License

下载


Fortran Testing Framework

A framework to help test Fortran compilers. Written by Agustin Forero for Argonne National Laboratory.

Click here to watch my seminar on this project!

A typical test might look like:

  1. $ ./run_test.sh gfortran
  2. $ ./run_test.sh bleedingedgecompiler
  3. $ ./compare.py gfortran bleedingedgecompiler

A flowchart describing runtime:

Diagram

Requirements:

Summary:

This is a framework built to help test bleeding-edge Fortran compilers. By testing the compilation of a wide variety of Fortran programs, and cross-checking results with stable compilers like gfortran, one can find where a compiler might be going wrong.

To add a directory containing Fortran programs to use for testing compilation, cd into /main/, and use ./addNew.sh <path-to-directory>.

Then, use ./run_test.sh (compiler) to compile all files found in the subdirectories of /source/. If no compiler is specified, it will use the current value of $FC (which is set to f77 by default within the Makefile). Each time ./run_test.sh is executed, the results will be saved to /logs/ as <compiler>.log, where you can view all compilation errors encountered during runtime.

Additionally, running ./compare.py <compiler1> <compiler2> (-b / -g / -v <col>) from the base directory outputs differences in errors between two given compilers, where:

  • no flag outputs differences without additional formatting,
  • -b outputs a very basic summary,
  • -g outputs only the first line in each error to a two-column table, and
  • -v <col> outputs errors in full to a two-column table with <col> columns on each side, up to 256.

Other commands include:

  • ./addMakefile.sh <directory>: creates a generic Makefile. Runs automatically during ./run_test.sh if no Makefile is present.
  • ./verify.sh: checks all subdirectories of /source/ for possible race conditions.
  • ./addEnv.sh <directory>: adds comm.env to a subdirectory, allowing BATS to use necessary environmental commands before compiling, e.g. module load.
  • ./cleanup.sh <directory>: helps delete and/or backup your .bats files. This is important for when you add or delete files from a source directory.
  • ./resetAll.sh: deletes all instances of tests.bats across all directories — that is, the BATS file generated during ./run_test.sh.

Scraping:

Scrapers can be immensely helpful with gathering huge swathes of data at once. Within the /scraping/ directory, one can find scraper.py, a Python program that can help pull multiple Fortran files from a single website. It will then save these files to a directory named from the website, at which point the user can use ./addNew.sh ../scraper/<directory> in /main/ to add the files. To use, type:

./scraper.py <website url> <path to files> <extension>

  • <website url>: the page on which links to each Fortran file are found.
  • <path to files>: URL path preceding each file location. Example below.
  • <extension>: the desired extension to search for and download, e.g. .f90.

Using the example of Michel Olagnon’s ORDERPACK 2.0, one might execute:

./scraper.py http://www.fortran-2000.com/rank/index.html http://www.fortran-2000.com/rank/ .f90

In this example, http://www.fortran-2000.com/rank/ is used as the second argument because every Fortran file on the page is located at http://www.fortran-2000.com/rank/<FILE.f90>.

Though not all of these need a scraper, other websites one might pull Fortran files from include:

A warning against race conditions:

Use ./verify.py from /main/ to check for possible race conditions!

For the files being compiled, it’s helpful that all files involved would already make perfectly with the -j flag. If there’s a problem with the code itself, both compilers will encounter it, which should be alright; but sometimes, race conditions present within directories can cause sporadic errors that do not occur every runtime, thereby rendering the testing inconsistent and therefore invalid.

For example, if a directory has multiple declarations of the same module across different files, multiple instances of make might try to write to <modulename>.mod at once during make, thereby allowing for a race condition. This mod will subsequently be corrupted when referenced later on.

In short, race conditions are bad.

Example output:

  1. $ ./compare.py gfortran flang
  2. ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  3. DIR: home/agustin/Projects/ftframework/source/bu
  4. DIFF_COUNT: gfortran: 0 flang: 1
  5. TOTAL_ERRORS: gfortran: 0 flang: 1
  6. ================================================================
  7. COMPILER: flang
  8. ERROR: real.o
  9. # flang -c real.f90
  10. # F90-S-0081-Illegal selector - KIND parameter has unknown value for data type (real.f90: 5)
  11. # F90-S-0034-Syntax error at or near identifier q0 (real.f90: 14)
  12. # 0 inform, 0 warnings, 2 severes, 0 fatal for MAIN
  13. # make: *** [Makefile:151: real.o] Error 1
  14. ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  15. DIR: home/agustin/Projects/ftframework/source/nasa_f
  16. DIFF_COUNT: gfortran: 0 flang: 10
  17. TOTAL_ERRORS: gfortran: 0 flang: 10
  18. ================================================================
  19. COMPILER: flang
  20. ERROR: prcset.o
  21. # flang -c prcset.f
  22. # flang-7: error: unable to execute command: Segmentation fault (core dumped)
  23. # flang-7: error: Fortran frontend to LLVM command failed due to signal (use -v to see invocation)
  24. # clang version 7.0.1
  25. # Target: x86_64-pc-linux-gnu
  26. # Thread model: posix
  27. # InstalledDir: /usr/bin
  28. # flang-7: note: diagnostic msg: PLEASE submit a bug report to and include the crash backtrace, preprocessed source, and associated run script.
  29. # flang-7: note: diagnostic msg: Error generating preprocessed source(s) - no preprocessable inputs.
  30. # make: *** [Makefile:433: prcset.o] Error 254
  31. ERROR: pool.o
  32. # flang -c pool.f
  33. # flang-7: error: unable to execute command: Segmentation fault (core dumped)
  34. # flang-7: error: Fortran frontend to LLVM command failed due to signal (use -v to see invocation)
  35. # clang version 7.0.1
  36. # Target: x86_64-pc-linux-gnu
  37. # Thread model: posix
  38. # InstalledDir: /usr/bin
  39. # flang-7: note: diagnostic msg: PLEASE submit a bug report to and include the crash backtrace, preprocessed source, and associated run script.
  40. # flang-7: note: diagnostic msg: Error generating preprocessed source(s) - no preprocessable inputs.
  41. # make: *** [Makefile:2179: pool.o] Error 254
  42. ERROR: zzdskbsr.o
  43. # flang -c zzdskbsr.f
  44. # /tmp/zzdskbsr-0fa576.ll:2936:12: error: '@_master___zzdskbsr__' defined with type 'void (i32, i64*, i64*, i64*, i64*, i64*, i64*, i64*, i64*, i64*, i64, i64*)*'
  45. # call void @_master___zzdskbsr__(i32 0, i64* %fname, i64* %bodyid, i64* %handle, i64* %cmpfun, i64* %usrctr, i64* %update, i64* %dladsc, i64* %dskdsc, i64* %found, i64* %cmpfun$sd, i64%.U0001.addr)
  46. # ^
  47. # 1 error generated.
  48. # make: *** [Makefile:3667: zzdskbsr.o] Error 1
  49. ERROR: zzgfdiu.o
  50. # flang -c zzgfdiu.f
  51. # /tmp/zzgfdiu-739e1b.ll:313:12: error: '@_master___zzgfdiu__' defined with type 'void (i32, i64*, i64*, i64*, i64*, i64*, i64*, i64*, i64, i64, i64, i64*)*'
  52. # call void @_master___zzgfdiu__(i32 0, i64* %target, i64* %abcorr, i64* %obsrvr, i64* %udfunc, i64* %et, i64* %decres, i64* %dist, i64* %udfunc$sd, i64%.U0003.addr, i64%.U0004.addr, i64%.U0005.addr)
  53. # ^
  54. # 1 error generated.
  55. # make: *** [Makefile:4297: zzgfdiu.o] Error 1
  56. ERROR: zzgfcou.o
  57. # flang -c zzgfcou.f
  58. # /tmp/zzgfcou-02d33d.ll:2110:12: error: '@_master___zzgfcou__' defined with type 'void (i32, i64*, i64*, i64*, i64*, i64*, i64*, i64*, i64*, i64*, i64*, i64*, i64*, i64*, i64*, i64*, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64*)*'
  59. # call void @_master___zzgfcou__(i32 0, i64* %vecdef, i64* %method, i64* %target, i64* %et, i64* %ref, i64* %abcorr, i64* %obsrvr, i64* %dref, i64* %dvec, i64* %crdsys, i64* %crdnam, i64* %decres, i64* %crdval, i64* %crdfnd, i64* %udfunc, i64* %udfunc$sd, i64%.U0009.addr, i64%.U0010.addr, i64%.U0011.addr, i64%.U0012.addr, i64%.U0013.addr, i64%.U0014.addr, i64%.U0015.addr, i64%.U0016.addr, i64%.U0017.addr)
  60. # ^
  61. # 1 error generated.
  62. # make: *** [Makefile:4285: zzgfcou.o] Error 1
  63. ERROR: zzgfilu.o
  64. # flang -c zzgfilu.f
  65. # /tmp/zzgfilu-0c1f3b.ll:788:12: error: '@_master___zzgfilu__' defined with type 'void (i32, i64*, i64*, i64*, i64*, i64*, i64*, i64*, i64*, i64*, i64*, i64*, i64*, i64, i64, i64, i64, i64, i64, i64, i64*)*'
  66. # call void @_master___zzgfilu__(i32 0, i64* %method, i64* %angtyp, i64* %target, i64* %illum, i64* %fixref, i64* %abcorr, i64* %obsrvr, i64* %spoint, i64* %et, i64* %udfunc, i64* %decres, i64* %angle, i64* %udfunc$sd, i64%.U0007.addr, i64%.U0008.addr, i64%.U0009.addr, i64%.U0010.addr, i64%.U0011.addr, i64%.U0012.addr, i64%.U0013.addr)
  67. # ^
  68. # 1 error generated.
  69. # make: *** [Makefile:4306: zzgfilu.o] Error 1
  70. ERROR: zzgfpau.o
  71. # flang -c zzgfpau.f
  72. # /tmp/zzgfpau-22f585.ll:552:12: error: '@_master___zzgfpau__' defined with type 'void (i32, i64*, i64*, i64*, i64*, i64*, i64*, i64*, i64*, i64*, i64*, i64*, i64*, i64*, i64, i64, i64, i64, i64, i64*)*'
  73. # call void @_master___zzgfpau__(i32 0, i64* %target, i64* %illmn, i64* %abcorr, i64* %obsrvr, i64* %udfunc, i64* %et, i64* %decres, i64* %rvl, i64* %xtarg, i64* %xillmn, i64* %xabcor, i64* %xobs, i64* %xablk, i64* %udfunc$sd, i64%.U0005.addr, i64%.U0006.addr, i64%.U0007.addr, i64%.U0008.addr, i64%.U0009.addr)
  74. # ^
  75. # 1 error generated.
  76. # make: *** [Makefile:4318: zzgfpau.o] Error 1
  77. ERROR: zzgfrru.o
  78. # flang -c zzgfrru.f
  79. # /tmp/zzgfrru-a1f258.ll:447:12: error: '@_master___zzgfrru__' defined with type 'void (i32, i64*, i64*, i64*, i64*, i64*, i64*, i64*, i64*, i64*, i64*, i64*, i64*, i64, i64, i64, i64, i64*)*'
  80. # call void @_master___zzgfrru__(i32 0, i64* %target, i64* %abcorr, i64* %obsrvr, i64* %dt, i64* %udfunc, i64* %et, i64* %decres, i64* %rvl, i64* %xtarg, i64* %xabcor, i64* %xobs, i64* %xdt, i64* %udfunc$sd, i64%.U0004.addr, i64%.U0005.addr, i64%.U0006.addr, i64%.U0007.addr)
  81. # ^
  82. # 1 error generated.
  83. # make: *** [Makefile:4336: zzgfrru.o] Error 1
  84. ERROR: zzgfspu.o
  85. # flang -c zzgfspu.f
  86. # /tmp/zzgfspu-f6f7b3.ll:1041:12: error: '@_master___zzgfspu__' defined with type 'void (i32, i64*, i64*, i64*, i64*, i64*, i64*, i64*, i64*, i64*, i64*, i64*, i64*, i64*, i64*, i64*, i64*, i64, i64, i64, i64, i64, i64, i64, i64, i64*)*'
  87. # call void @_master___zzgfspu__(i32 0, i64* %of, i64* %from, i64* %shape, i64* %frame, i64* %et, i64* %udfunc, i64* %abcorr, i64* %decres, i64* %sep, i64* %xabcr, i64* %xbod, i64* %yref, i64* %xref, i64* %xobs, i64* %xrad, i64* %xshp, i64* %udfunc$sd, i64%.U0008.addr, i64%.U0009.addr, i64%.U0010.addr, i64%.U0011.addr, i64%.U0012.addr, i64%.U0013.addr, i64%.U0014.addr, i64%.U0015.addr)
  88. # ^
  89. # 1 error generated.
  90. # make: *** [Makefile:4348: zzgfspu.o] Error 1
  91. ERROR: tabrpt.o
  92. # flang -c tabrpt.f
  93. # /tmp/tabrpt-ca1837.ll:1687:12: error: '@_master___tabrpt__' defined with type 'void (i32, i64*, i64*, i64*, i64*, i64*, i64*, i64*, i64*, i64*, i64*, i64, i64*)*'
  94. # call void @_master___tabrpt__(i32 0, i64* %nitems, i64* %item, i64* %size, i64* %width, i64* %justr, i64* %presrv, i64* %spcial, i64* %lmarge, i64* %space, i64* %fetch, i64* %fetch$sd, i64%.U0001.addr)
  95. # ^
  96. # 1 error generated.
  97. # make: *** [Makefile:5314: tabrpt.o] Error 1
  1. $ ./compare.py gfortran flang -b
  2. ================================================================
  3. DIR: home/agustin/Projects/ftframework/source/bu
  4. DIFF_COUNT: gfortran: 0 flang: 1
  5. TOTAL_ERRORS: gfortran: 0 flang: 1
  6. COMPILER: flang
  7. real.o
  8. ================================================================
  9. DIR: home/agustin/Projects/ftframework/source/nasa_f
  10. DIFF_COUNT: gfortran: 0 flang: 10
  11. TOTAL_ERRORS: gfortran: 0 flang: 10
  12. COMPILER: flang
  13. prcset.o
  14. pool.o
  15. zzdskbsr.o
  16. zzgfdiu.o
  17. zzgfcou.o
  18. zzgfilu.o
  19. zzgfpau.o
  20. zzgfrru.o
  21. zzgfspu.o
  22. tabrpt.o
  1. $ ./compare.py gfortran flang -g
  2. gfortran | flang
  3. 0 -------------- /source/bu ------------- 1
  4. | real.o
  5. |
  6. 0 ----------- /source/nasa_f ----------- 10
  7. | prcset.o
  8. | pool.o
  9. | zzdskbsr.o
  10. | zzgfdiu.o
  11. | zzgfcou.o
  12. | zzgfilu.o
  13. | zzgfpau.o
  14. | zzgfrru.o
  15. | zzgfspu.o
  16. | tabrpt.o
  17. |
  1. $ ./compare.py gfortran flang -v 48
  2. gfortran | flang
  3. 0 ------------------------------------------ /source/bu ----------------------------------------- 1
  4. | real.o
  5. |
  6. | # flang -c real.f90
  7. | # F90-S-0081-Illegal selector - KIND paramete...
  8. | # F90-S-0034-Syntax error at or near identifi...
  9. | # 0 inform, 0 warnings, 2 severes, 0 fa...
  10. | # make: *** [Makefile:151: real.o] Error 1
  11. |
  12. | ------------------------------------------------
  13. |
  14. 0 --------------------------------------- /source/nasa_f --------------------------------------- 10
  15. | prcset.o
  16. |
  17. | # flang -c prcset.f
  18. | # flang-7: error: unable to execute command: ...
  19. | # flang-7: error: Fortran frontend to LLVM co...
  20. | # clang version 7.0.1
  21. | # Target: x86_64-pc-linux-gnu
  22. | # Thread model: posix
  23. | # InstalledDir: /usr/bin
  24. | # flang-7: note: diagnostic msg: PLEASE submi...
  25. | # flang-7: note: diagnostic msg: Error genera...
  26. | # make: *** [Makefile:433: prcset.o] Error 254
  27. |
  28. | ------------------------------------------------
  29. | pool.o
  30. |
  31. | # flang -c pool.f
  32. | # flang-7: error: unable to execute command: ...
  33. | # flang-7: error: Fortran frontend to LLVM co...
  34. | # clang version 7.0.1
  35. | # Target: x86_64-pc-linux-gnu
  36. | # Thread model: posix
  37. | # InstalledDir: /usr/bin
  38. | # flang-7: note: diagnostic msg: PLEASE submi...
  39. | # flang-7: note: diagnostic msg: Error genera...
  40. | # make: *** [Makefile:2179: pool.o] Error 254
  41. |
  42. | ------------------------------------------------
  43. | zzdskbsr.o
  44. |
  45. | # flang -c zzdskbsr.f
  46. | # /tmp/zzdskbsr-0fa576.ll:2936:12: error: '@_...
  47. | # call void @_master___zzdskbsr__(i32...
  48. | # ^
  49. | # 1 error generated.
  50. | # make: *** [Makefile:3667: zzdskbsr.o] Error 1
  51. |
  52. | ------------------------------------------------
  53. | zzgfdiu.o
  54. |
  55. | # flang -c zzgfdiu.f
  56. | # /tmp/zzgfdiu-739e1b.ll:313:12: error: '@_ma...
  57. | # call void @_master___zzgfdiu__(i32 ...
  58. | # ^
  59. | # 1 error generated.
  60. | # make: *** [Makefile:4297: zzgfdiu.o] Error 1
  61. |
  62. | ------------------------------------------------
  63. | zzgfcou.o
  64. |
  65. | # flang -c zzgfcou.f
  66. | # /tmp/zzgfcou-02d33d.ll:2110:12: error: '@_m...
  67. | # call void @_master___zzgfcou__(i32 ...
  68. | # ^
  69. | # 1 error generated.
  70. | # make: *** [Makefile:4285: zzgfcou.o] Error 1
  71. |
  72. | ------------------------------------------------
  73. | zzgfilu.o
  74. |
  75. | # flang -c zzgfilu.f
  76. | # /tmp/zzgfilu-0c1f3b.ll:788:12: error: '@_ma...
  77. | # call void @_master___zzgfilu__(i32 ...
  78. | # ^
  79. | # 1 error generated.
  80. | # make: *** [Makefile:4306: zzgfilu.o] Error 1
  81. |
  82. | ------------------------------------------------
  83. | zzgfpau.o
  84. |
  85. | # flang -c zzgfpau.f
  86. | # /tmp/zzgfpau-22f585.ll:552:12: error: '@_ma...
  87. | # call void @_master___zzgfpau__(i32 ...
  88. | # ^
  89. | # 1 error generated.
  90. | # make: *** [Makefile:4318: zzgfpau.o] Error 1
  91. |
  92. | ------------------------------------------------
  93. | zzgfrru.o
  94. |
  95. | # flang -c zzgfrru.f
  96. | # /tmp/zzgfrru-a1f258.ll:447:12: error: '@_ma...
  97. | # call void @_master___zzgfrru__(i32 ...
  98. | # ^
  99. | # 1 error generated.
  100. | # make: *** [Makefile:4336: zzgfrru.o] Error 1
  101. |
  102. | ------------------------------------------------
  103. | zzgfspu.o
  104. |
  105. | # flang -c zzgfspu.f
  106. | # /tmp/zzgfspu-f6f7b3.ll:1041:12: error: '@_m...
  107. | # call void @_master___zzgfspu__(i32 ...
  108. | # ^
  109. | # 1 error generated.
  110. | # make: *** [Makefile:4348: zzgfspu.o] Error 1
  111. |
  112. | ------------------------------------------------
  113. | tabrpt.o
  114. |
  115. | # flang -c tabrpt.f
  116. | # /tmp/tabrpt-ca1837.ll:1687:12: error: '@_ma...
  117. | # call void @_master___tabrpt__(i32 0...
  118. | # ^
  119. | # 1 error generated.
  120. | # make: *** [Makefile:5314: tabrpt.o] Error 1
  121. |
  122. | ------------------------------------------------
  123. |