Skip to content

Commit

Permalink
Merge pull request #4 from jalvesz/dev
Browse files Browse the repository at this point in the history
update main from dev
  • Loading branch information
jalvesz committed May 10, 2024
2 parents ec22057 + ac2a1cd commit bf71378
Show file tree
Hide file tree
Showing 31 changed files with 7,418 additions and 844 deletions.
19 changes: 6 additions & 13 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,18 @@ jobs:
- os: ubuntu-latest
toolchain: {compiler: intel-classic, version: '2021.10', flags: ['-fpp -O3 -xhost']}
- os: ubuntu-latest
toolchain: {compiler: intel, version: '2024.0.1', flags: ['-fpp -O3 -xhost']}
toolchain: {compiler: intel, version: '2024.1', flags: ['-fpp -O3 -xhost']}
- os: ubuntu-latest
toolchain: {compiler: nvidia-hpc, version: '24.1', flags: ['-Mpreprocess -Ofast']}
- os: windows-latest
toolchain: {compiler: gcc, version: 13, flags: ['-cpp -O3 -march=native -mtune=native']}
- os: windows-latest
toolchain: {compiler: intel-classic, version: '2021.10', flags: ['-fpp -O3 -QxHost']}
toolchain: {compiler: intel-classic, version: '2021.10', flags: ["/fpp /O3"]}
- os: windows-latest
toolchain: {compiler: intel, version: '2024.0.1', flags: ['-fpp -O3 -QxHost']}
- os: macos-latest
toolchain: {compiler: intel, version: '2024.1', flags: ["/fpp /O3"]}
- os: macos-12
toolchain: {compiler: gcc, version: 13, flags: ['-cpp -O3 -march=native -mtune=native']}
- os: macos-latest
- os: macos-12
toolchain: {compiler: intel-classic, version: '2021.10', flags: ['-fpp -O3 -xhost']}

steps:
Expand All @@ -45,12 +45,5 @@ jobs:
with:
github-token: ${{ secrets.GITHUB_TOKEN }}

- name: Setup Fortran on MacOS
if: contains( matrix.os, 'macos')
run: |
brew reinstall gcc@13
ln -s /usr/local/lib/gcc/13/libgfortran.5.dylib /usr/local/lib/
ln -s /usr/local/lib/gcc/13/libquadmath.0.dylib /usr/local/lib/
- run: |
fpm test --flag "${{ join(matrix.toolchain.flags, ' ') }}"
fpm test --flag "${{ join(matrix.toolchain.flags, ' ') }}"
31 changes: 21 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ Available Matrices
| CSR | `CSR_t` | `CSR_?p` | `CSR_c?p` |
| CSC | `CSC_t` | `CSC_?p` | `CSC_c?p` |
| ELL | `ELL_t` | `ELL_?p` | `ELL_c?p` |
| SELL-C | `SELLC_t` | `SELLC_?p` | `SELLC_c?p` |

COO: COordinate Sparse format

Expand All @@ -25,6 +26,8 @@ CSC: Compressed Sparse Column format

ELL: ELLPACK

SELL-C: sliced ELLPACK format

(Where `?` stands for the precision s,d,q)

Available Kernels
Expand All @@ -34,25 +37,29 @@ Conversion subroutines follow the naming pattern _sourcetype2targettype_m ex:
```fortran
call dense2coo( dense , coo )
```
| Matrix | dense | COO | CSR | CSC | ELL |
|--------|-------|-------|-------|-------|-------|
| dense | || | | |
| COO || || | |
| CSR | || | | |
| CSC | | | | | |
| ELL | | | | | |
| Matrix | dense | COO | CSR |
|--------|-------|-------|-------|
| dense | || |
| COO || ||
| CSR | || |
| CSC | | | |
| ELL | | | |
| SELL-C | | ||

### Sparse Matrix-Vector product
(availbale) Matrix vector products are interfaced by the procedure
(available) Matrix vector products are interfaced by the procedure
```fortran
call matvec( Mat , vec_x, vec_y ) ! vec_y = Mat * vec_x
```
**NOTE**: The matvec in this lib do not initialize `vec_y=0`. Why? enable easy recycling of data to do `vec_y=vec_y+Mat*vec_x`. If a clean vector is needed make sure to put a `vec_y=0` just before calling matvec.

| Matrix | full | symmetric |
|--------|-------|------------------|
| COO |||
| CSR |||
| CSC || |
| CSC || (?) |
| ELL |||
| SELL-C |||

A taste of FSPARSE
==================
Expand Down Expand Up @@ -123,13 +130,17 @@ Inspiration & References

[Calcul Scientifique Parallèle](https://www.dunod.com/sciences-techniques/calcul-scientifique-parallele-cours-exemples-avec-openmp-et-mpi-exercices-0)

[Implementing a Sparse Matrix Vector Product for the SELL-C/SELL-C-σ formats on NVIDIA GPUs](https://library.eecs.utk.edu/storage/files/ut-eecs-14-727.pdf)

Authors and contributors
========================

+ [José R. Alves Z.](https://www.researchgate.net/profile/Jose-Alves-25)
+ Mechanical Engineer, Researcher, Scientific Software Developer
+ [Samuele Giuli](https://github.com/SamueleGiuli)
+ [Ivan Privec](https://github.com/ivan-pi)

Acknowledgement
===============

Compilation of this library was possible thanks to [Transvalor S.A.](https://www.transvalor.com/en/homepage) research activities
Compilation of this library was possible thanks to [Transvalor S.A.](https://www.transvalor.com/en/homepage) research activities
102 changes: 81 additions & 21 deletions deployement.py
Original file line number Diff line number Diff line change
@@ -1,37 +1,97 @@
import os
import subprocess
import fypp
import argparse
from joblib import Parallel, delayed

def apply_command(with_qp, with_xqp, with_hp):
# Get a list of all files in the folder
# Filter files based on the provided extension
folder = '.\src'
lfiles = os.listdir(folder)
files = [folder+os.sep+file for file in lfiles if file.endswith(".fypp")]

args = []
if with_qp:
args.append("-DWITH_QP=True")
if with_xqp:
args.append("-DWITH_XQP=True")
if with_hp:
args.append("-DWITH_HP=True")
C_PREPROCESSED = (

)

def pre_process_toml(kargs):
"""Pre process mannifest
fpm.toml mannifest file can be edited to account for custom keywords
Parameters
----------
kargs : str
collection of command line arguments.
"""
from tomlkit import table, dumps
data = table()
data.add("name", "fsparse")
data.add("version", str(kargs.vmajor)+
"."+str(kargs.vminor)+
"."+str(kargs.vpatch) )
data.add("license", "MIT")
data.add("author", "José Alves")
data.add("maintainer", "jose.alves@transvalor.com")
data.add("copyright", "Copyright 2023, Jose Alves")

dev_dependencies = table()
dev_dependencies.add("test-drive", {"git" : "https://github.com/fortran-lang/test-drive",
"tag" : "v0.4.0"})
data.add("dev-dependencies", dev_dependencies)

preprocess = table()
preprocess.add("cpp", {} )
preprocess['cpp'].add("suffixes", [".f90"] )
# preprocess['cpp'].add("macros", [] )
data.add("preprocess", preprocess)

with open("fpm.toml", "w") as f:
f.write(dumps(data))

def pre_process_fypp(kargs):
"""Pre process fypp files
Parameters
----------
kargs : str
collection of command line arguments.
"""
kwd = []
if kargs.with_qp:
kwd.append("-DWITH_QP=True")
if kargs.with_xqp:
kwd.append("-DWITH_XDP=True")

optparser = fypp.get_option_parser()
options, leftover = optparser.parse_args(args=args)
options, leftover = optparser.parse_args(args=kwd)
options.includes = ['include'] #folder with include files for fypp
# options.line_numbering = True
tool = fypp.Fypp(options)
# Apply the command line to each file
for file in files:

# Define the folders to search for *.fypp files
folders = ['src', 'test']
# Process all folders
fypp_files = [os.path.join(root, file) for folder in folders
for root, _, files in os.walk(folder)
for file in files if file.endswith(".fypp")]

def process_f(file):
source_file = file
target_file = file.removesuffix('fypp')+'f90'
basename = os.path.splitext(source_file)[0]
sfx = 'f90' # if os.path.basename(basename) not in C_PREPROCESSED else 'F90'
target_file = basename + '.' + sfx
tool.process_file(source_file, target_file)

Parallel(n_jobs=kargs.njob)(delayed(process_f)(f) for f in fypp_files)

return

if __name__ == "__main__":
parser = argparse.ArgumentParser(description='Preprocess FSPARSE source files.')
# fypp arguments
parser.add_argument("--vmajor", type=int, default=0, help="Project Version Major")
parser.add_argument("--vminor", type=int, default=1, help="Project Version Minor")
parser.add_argument("--vpatch", type=int, default=1, help="Project Version Patch")

parser.add_argument("--njob", type=int, default=4, help="number of parallel jobs")
parser.add_argument("--with_qp", action="store_true", help="Include WITH_QP in the command")
parser.add_argument("--with_xqp", action="store_true", help="Include WITH_XQP in the command")
parser.add_argument("--with_hp", action="store_true", help="Include WITH_HP in the command")

args = parser.parse_args()
apply_command(args.with_qp, args.with_xqp, args.with_hp)

pre_process_toml(args)
pre_process_fypp(args)
Loading

0 comments on commit bf71378

Please sign in to comment.