Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 14 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -111,19 +111,19 @@ Run from this repository:

| Library | Command | Writes |
|---|---|---|
| HIP | `ROCM_SYSTEMS=<rocm-systems> ./gen.sh --overwrite hip` | `projects/fortran/hip.F90` |
| ROCTx | `ROCM_SYSTEMS=<rocm-systems> ./gen.sh --overwrite roctx` | `projects/fortran/roctx.F90` |
| rocBLAS | `ROCM_LIBRARIES=<rocm-libraries> ./gen.sh --overwrite rocblas` | `projects/rocblas/fortran/rocblas.F90` |
| hipBLAS | `ROCM_LIBRARIES=<rocm-libraries> ./gen.sh --overwrite hipblas` | `projects/hipblas/fortran/hipblas.F90` |
| rocSOLVER | `ROCM_LIBRARIES=<rocm-libraries> ./gen.sh --overwrite rocsolver` | `projects/rocsolver/fortran/rocsolver.F90` |
| hipSOLVER | `ROCM_LIBRARIES=<rocm-libraries> ./gen.sh --overwrite hipsolver` | `projects/hipsolver/fortran/hipsolver.F90` |
| rocSPARSE | `ROCM_LIBRARIES=<rocm-libraries> ./gen.sh --overwrite rocsparse` | `projects/rocsparse/fortran/rocsparse.F90` |
| hipSPARSE | `ROCM_LIBRARIES=<rocm-libraries> ./gen.sh --overwrite hipsparse` | `projects/hipsparse/fortran/hipsparse.F90` |
| rocFFT | `ROCM_LIBRARIES=<rocm-libraries> ./gen.sh --overwrite rocfft` | `projects/rocfft/fortran/rocfft.F90` |
| hipFFT | `ROCM_LIBRARIES=<rocm-libraries> ./gen.sh --overwrite hipfft` | `projects/hipfft/fortran/hipfft.F90` |
| hipFFTW | `ROCM_LIBRARIES=<rocm-libraries> ./gen.sh --overwrite hipfftw` | `projects/hipfft/fortran/hipfftw.F90` |
| rocRAND | `ROCM_LIBRARIES=<rocm-libraries> ./gen.sh --overwrite rocrand` | `projects/rocrand/fortran/rocrand.F90` |
| hipRAND | `ROCM_LIBRARIES=<rocm-libraries> ./gen.sh --overwrite hiprand` | `projects/hiprand/fortran/hiprand.F90` |
| HIP | `ROCM_SYSTEMS=<rocm-systems> ./gen.sh --overwrite hip` | `bindings/fortran/hip.F90` |
| ROCTx | `ROCM_SYSTEMS=<rocm-systems> ./gen.sh --overwrite roctx` | `bindings/fortran/roctx.F90` |
| rocBLAS | `ROCM_LIBRARIES=<rocm-libraries> ./gen.sh --overwrite rocblas` | `bindings/fortran/rocblas/rocblas.F90` |
| hipBLAS | `ROCM_LIBRARIES=<rocm-libraries> ./gen.sh --overwrite hipblas` | `bindings/fortran/hipblas/hipblas.F90` |
| rocSOLVER | `ROCM_LIBRARIES=<rocm-libraries> ./gen.sh --overwrite rocsolver` | `bindings/fortran/rocsolver/rocsolver.F90` |
| hipSOLVER | `ROCM_LIBRARIES=<rocm-libraries> ./gen.sh --overwrite hipsolver` | `bindings/fortran/hipsolver/hipsolver.F90` |
| rocSPARSE | `ROCM_LIBRARIES=<rocm-libraries> ./gen.sh --overwrite rocsparse` | `bindings/fortran/rocsparse/rocsparse.F90` |
| hipSPARSE | `ROCM_LIBRARIES=<rocm-libraries> ./gen.sh --overwrite hipsparse` | `bindings/fortran/hipsparse/hipsparse.F90` |
| rocFFT | `ROCM_LIBRARIES=<rocm-libraries> ./gen.sh --overwrite rocfft` | `bindings/fortran/rocfft/rocfft.F90` |
| hipFFT | `ROCM_LIBRARIES=<rocm-libraries> ./gen.sh --overwrite hipfft` | `bindings/fortran/hipfft/hipfft.F90` |
| hipFFTW | `ROCM_LIBRARIES=<rocm-libraries> ./gen.sh --overwrite hipfftw` | `bindings/fortran/hipfft/hipfftw.F90` |
| rocRAND | `ROCM_LIBRARIES=<rocm-libraries> ./gen.sh --overwrite rocrand` | `bindings/fortran/rocrand/rocrand.F90` |
| hipRAND | `ROCM_LIBRARIES=<rocm-libraries> ./gen.sh --overwrite hiprand` | `bindings/fortran/hiprand/hiprand.F90` |

`<rocm-systems>` and `<rocm-libraries>` are the paths of your checkouts, and the
last column is relative to them. Several libraries can be named in one run
Expand Down Expand Up @@ -312,7 +312,7 @@ Without it, `alpha` and `beta` would be buffers: arrays of one element.

| | |
|---|---|
| **where** | `src/<lib>/metadata/<lib>.toml` in the generator; when a run reads a checkout, the checkout's own `metadata/` next to the module replaces it (`projects/fortran/metadata/` in rocm-systems, `projects/<proj>/fortran/metadata/` in rocm-libraries) |
| **where** | `src/<lib>/metadata/<lib>.toml` in the generator; when a run reads a checkout, the checkout's own `metadata/` next to the module replaces it (`bindings/fortran/metadata/` in rocm-systems, `bindings/fortran/<proj>/metadata/` in rocm-libraries) |
| **none** | a missing or empty file means no metadata: the C declarations alone |
| **`format = 1`** | required as soon as there is an entry; the version of this schema, not of the generator |
| **tables** | one per C function, keyed by its arguments' names as the C header spells them |
Expand Down
8 changes: 4 additions & 4 deletions gen.sh
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,13 @@ note: Both: all libraries, from the two checkouts only (no ROCm installation).
note: Libraries named on the command line (hip, roctx, rocblas, hipfft, ...) are the
note: only ones generated; each must come from a header source the run reads.
note: --overwrite also copies each generated module into its checkout:
note: <ROCM_LIBRARIES>/projects/<proj>/fortran/<lib>.F90, or
note: <ROCM_SYSTEMS>/projects/fortran/<lib>.F90. It needs a checkout, the fortran/
note: <ROCM_LIBRARIES>/bindings/fortran/<proj>/<lib>.F90, or
note: <ROCM_SYSTEMS>/bindings/fortran/<lib>.F90. It needs a checkout, the binding's
note: directory must already exist there, and a library that fails is not copied.
note: A run rewrites only the modules it generates: fortran/rocm-systems/fortran/
note: (HIP, ROCTx) and fortran/rocm-libraries/<lib>/ (the math libraries).
note: A checkout's fortran/metadata/<lib>.toml (rocm-systems: projects/fortran/metadata/;
note: rocm-libraries: projects/<proj>/fortran/metadata/), when present, replaces the
note: A checkout's metadata/<lib>.toml (rocm-systems: bindings/fortran/metadata/;
note: rocm-libraries: bindings/fortran/<proj>/metadata/), when present, replaces the
note: generator's src/<lib>/metadata/ for that library.
note: The Julia dependencies are installed on the first run (Pkg.instantiate).
note: fortran/ is gitignored: the bindings are committed upstream, next to the
Expand Down
10 changes: 5 additions & 5 deletions src/common/header_sources.jl
Original file line number Diff line number Diff line change
Expand Up @@ -125,10 +125,10 @@ function lib_include(s::HeaderSources, lib)
end

# The directory of a library's Fortran module in its checkout: one shared
# projects/fortran/ in rocm-systems, projects/<proj>/fortran/ in rocm-libraries.
# bindings/fortran/ in rocm-systems, bindings/fortran/<proj>/ in rocm-libraries.
fortran_dir(s::HeaderSources, lib) =
repo_of(lib) == "rocm-systems" ? joinpath(s.systems, "projects", "fortran") :
joinpath(s.libraries, "projects", proj_of(lib), "fortran")
repo_of(lib) == "rocm-systems" ? joinpath(s.systems, "bindings", "fortran") :
joinpath(s.libraries, "bindings", "fortran", proj_of(lib))

# The path --overwrite writes a library's module to, in its checkout.
overwrite_target(s::HeaderSources, lib) = joinpath(fortran_dir(s, lib), "$(lib).F90")
Expand Down Expand Up @@ -181,7 +181,7 @@ end
check_overwrite(s, libs)

Throws an `ArgumentError` unless --overwrite can write every module of `libs`: the
run reads a checkout, and each library's fortran/ directory already exists in it.
run reads a checkout, and each library's binding directory already exists in it.
Called before generating anything, so a run that cannot finish writes nothing.
"""
function check_overwrite(s::HeaderSources, libs)
Expand All @@ -197,7 +197,7 @@ end
# A library's metadata file (metadata/<lib>.toml): the checkout's
# <fortran_dir>/metadata/ when it exists, else the generator's own
# src/<lib>/metadata/. The file names carry the library name, so the modules sharing
# a fortran/ directory (hip and roctx, hipfft and hipfftw) share one metadata/.
# a binding directory (hip and roctx, hipfft and hipfftw) share one metadata/.
function lib_metadata(s::HeaderSources, lib)
if from_checkouts(s)
d = joinpath(fortran_dir(s, lib), "metadata")
Expand Down
12 changes: 6 additions & 6 deletions src/generate_all.jl
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,11 @@
# Options, before the positional arguments:
# --libs=<lib>[,<lib>...] generate only these libraries (each must be one the run selects)
# --overwrite also copy each generated module into its checkout, as
# <rocm-libraries>/projects/<proj>/fortran/<lib>.F90 or
# <rocm-systems>/projects/fortran/<lib>.F90; needs a checkout,
# and that fortran/ directory must already exist
# <rocm-libraries>/bindings/fortran/<proj>/<lib>.F90 or
# <rocm-systems>/bindings/fortran/<lib>.F90; needs a checkout,
# and that directory must already exist
#
# Each library's metadata files come from its checkout's projects/<proj>/fortran/metadata/
# Each library's metadata files come from its checkout's bindings/fortran/<proj>/metadata/
# when the run reads that checkout and the directory exists, else from src/<lib>/metadata/.

if any(in(("-h", "--help")), ARGS)
Expand Down Expand Up @@ -81,7 +81,7 @@ end
const OUTPUT_ROOT = abspath(isempty(REST) ? joinpath(@__DIR__, "..", "fortran") : REST[1])
const HIP_VERSION = hip_version(SOURCES)

# rocm-systems keeps its modules in one projects/fortran/ directory.
# rocm-systems keeps its modules in one bindings/fortran/ directory.
outdir_of(lib) = repo_of(lib) == "rocm-systems" ? joinpath(OUTPUT_ROOT, "rocm-systems", "fortran") :
joinpath(OUTPUT_ROOT, "rocm-libraries", lib)

Expand Down Expand Up @@ -156,7 +156,7 @@ write(joinpath(OUTPUT_ROOT, ".provenance"), """
hip: $(HIP_VERSION)
metadata: $(let ck = filter(l -> !startswith(lib_metadata(SOURCES, l), normpath(@__DIR__)), generated)
isempty(ck) ? "generator (src/<lib>/metadata/)" :
"checkout fortran/metadata/ for $(join(ck, " ")), generator for the others"
"checkout metadata/ for $(join(ck, " ")), generator for the others"
end)
arrays: $(get(ENV, "ROCM_FORTRAN_ARRAY_INTERFACES", "all"))
generator: $(GENERATOR_VERSION) ($(commit))
Expand Down
7 changes: 4 additions & 3 deletions src/test/gen_sh.sh
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ expect 1 "it comes from rocm-systems, so set ROCM_SYSTEMS" \
env ROCM_INCLUDE="$INST" ROCM_LIBRARIES="$LIBS" ./gen.sh hip
expect 1 "--overwrite needs ROCM_LIBRARIES or ROCM_SYSTEMS" \
env ROCM_INCLUDE="$INST" ./gen.sh --overwrite rocblas
expect 1 "projects/rocblas/fortran does not exist" \
expect 1 "bindings/fortran/rocblas does not exist" \
env ROCM_INCLUDE="$INST" ROCM_LIBRARIES="$LIBS" ./gen.sh --overwrite rocblas
expect 0 "C signature: headers not read; no HIP headers" \
env ROCM_INCLUDE="$TMP/empty" ./gen.sh --explain rocblas_srot_64
Expand All @@ -76,9 +76,10 @@ expect 1 "FAILED to generate" env ROCM_INCLUDE="$INST" ./gen.sh # an empty hip
# --explain, from a rocm-libraries checkout holding the fixture rocblas.h and its
# metadata: one parse, whatever the number of functions named.
CK="$TMP/ck/projects/rocblas"
mkdir -p "$CK/library/include" "$CK/fortran/metadata"
META="$TMP/ck/bindings/fortran/rocblas/metadata"
mkdir -p "$CK/library/include" "$META"
cp src/test/fixtures/explain/rocblas.h "$CK/library/include/"
cp src/test/fixtures/explain/rocblas.toml "$CK/fortran/metadata/"
cp src/test/fixtures/explain/rocblas.toml "$META/"
out="$(env ROCM_INCLUDE="$INST" ROCM_LIBRARIES="$TMP/ck" \
./gen.sh --explain rocblas_daxpy rocblas_dfoo_buffer_size rocblas_dbar rocblas_dnope 2>&1)"
for text in \
Expand Down
22 changes: 11 additions & 11 deletions src/test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1234,14 +1234,14 @@ overlong_fortran_lines(s::AbstractString) =
@test lib_include(s, "rocblas") == joinpath(libs, "projects", "rocblas", "library", "include")
@test hip_installed_include(s) == "" && hip_version(s) == "7.17.3"

# Metadata: a checkout's projects/<proj>/fortran/metadata/ replaces src/<lib>/metadata/.
# Metadata: a checkout's bindings/fortran/<proj>/metadata/ replaces src/<lib>/metadata/.
gen_meta(lib) = joinpath(GEN_ROOT, lib, "metadata")
mkpath(joinpath(libs, "projects", "hipfft", "fortran", "metadata"))
mkpath(joinpath(sys, "projects", "fortran", "metadata"))
@test lib_metadata(s, "hipfft") == joinpath(libs, "projects", "hipfft", "fortran", "metadata")
@test lib_metadata(s, "hipfftw") == joinpath(libs, "projects", "hipfft", "fortran", "metadata")
@test lib_metadata(s, "roctx") == joinpath(sys, "projects", "fortran", "metadata")
@test lib_metadata(s, "hip") == joinpath(sys, "projects", "fortran", "metadata")
mkpath(joinpath(libs, "bindings", "fortran", "hipfft", "metadata"))
mkpath(joinpath(sys, "bindings", "fortran", "metadata"))
@test lib_metadata(s, "hipfft") == joinpath(libs, "bindings", "fortran", "hipfft", "metadata")
@test lib_metadata(s, "hipfftw") == joinpath(libs, "bindings", "fortran", "hipfft", "metadata")
@test lib_metadata(s, "roctx") == joinpath(sys, "bindings", "fortran", "metadata")
@test lib_metadata(s, "hip") == joinpath(sys, "bindings", "fortran", "metadata")
@test lib_metadata(s, "rocblas") == gen_meta("rocblas") # no metadata in the checkout
let (si, _) = header_sources(Dict{String,String}(), [inst, out])
@test lib_metadata(si, "hipfft") == gen_meta("hipfft") # installed: never a checkout
Expand All @@ -1260,12 +1260,12 @@ overlong_fortran_lines(s::AbstractString) =
@test_throws ArgumentError run_libs(sl, ["rocblass"]) # not a library
@test_throws ArgumentError run_libs(sl, ["hip"]) # rocm-systems is not read
@test overwrite_target(sl, "hipfftw") ==
joinpath(libs, "projects", "hipfft", "fortran", "hipfftw.F90")
@test_throws ArgumentError check_overwrite(sl, ["rocblas"]) # no rocblas/fortran/ yet
mkpath(joinpath(libs, "projects", "rocblas", "fortran"))
joinpath(libs, "bindings", "fortran", "hipfft", "hipfftw.F90")
@test_throws ArgumentError check_overwrite(sl, ["rocblas"]) # no bindings/fortran/rocblas/ yet
mkpath(joinpath(libs, "bindings", "fortran", "rocblas"))
@test check_overwrite(sl, ["rocblas", "hipfftw"]) === nothing
end
@test overwrite_target(s, "roctx") == joinpath(sys, "projects", "fortran", "roctx.F90")
@test overwrite_target(s, "roctx") == joinpath(sys, "bindings", "fortran", "roctx.F90")
let (si, _) = header_sources(Dict{String,String}(), [inst, out])
@test_throws ArgumentError check_overwrite(si, ["rocblas"]) # installed: no checkout
end
Expand Down