{"id":15983526,"url":"https://github.com/ccoreilly/clapack-wasm","last_synced_at":"2025-04-04T20:33:38.798Z","repository":{"id":107871422,"uuid":"405740032","full_name":"ccoreilly/clapack-wasm","owner":"ccoreilly","description":null,"archived":false,"fork":false,"pushed_at":"2021-09-12T19:56:32.000Z","size":5907,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-10T05:13:37.622Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"C","has_issues":false,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ccoreilly.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-09-12T19:55:53.000Z","updated_at":"2023-02-23T05:07:46.000Z","dependencies_parsed_at":null,"dependency_job_id":"3d256591-eae1-4b59-aea7-2f025ed264f8","html_url":"https://github.com/ccoreilly/clapack-wasm","commit_stats":{"total_commits":55,"total_committers":2,"mean_commits":27.5,"dds":"0.036363636363636376","last_synced_commit":"47d831c8c29af577604b2a99d43dd9b030ea3dbe"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ccoreilly%2Fclapack-wasm","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ccoreilly%2Fclapack-wasm/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ccoreilly%2Fclapack-wasm/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ccoreilly%2Fclapack-wasm/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ccoreilly","download_url":"https://codeload.github.com/ccoreilly/clapack-wasm/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247248248,"owners_count":20908114,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-08T01:42:55.654Z","updated_at":"2025-04-04T20:33:38.765Z","avatar_url":"https://github.com/ccoreilly.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# README\n\n## Overview\n\nThis repo contains a tested version of CBLAS with BLAS, both entirely written\nin C. Having all soure code in C allows to easily convert the library to WASM.\n\nCLAPACK is also included but no tests were run.\n\nFor install instructions, please refer to [INSTALL](./INSTALL.md).\n\nThis repository contains the following directories\n\n```bash\n.\n├── CBLAS/\n├── CLAPACK-3.2.1/\n├── f2c_BLAS-3.8.0/\n├── libf2c/\n└── patches/\n```\n\n* `CLAPACK` contains the CLAPACK source code with redundancies (e.g. BLAS)\n  removed.\n* `CBLAS` contains the original source code of CBLAS\n* `f2c_BLAS-3.8.0` contains the source code of BLAS-3.8.0 converted to C using the\n  `f2c` program. For more information about this conversion, please this\n  [section](#automatic-fortran-77-to-c-translation).\n* `libf2c` contains functions and structure definition required by `f2c` converted\n  programs to run.\n\nThe dependencies look as follows:\n\n```mermaid\ngraph TD\n  BLAS --\u003e libf2c\n  CBLAS --\u003e BLAS\n  CLAPACK --\u003e libf2c\n  CLAPACK --\u003e CBLAS\n```\n\nTo avoid breaking the license of CBLAS, CLAPACK or BLAS, the source code of\nthese libraries is distributed as found in the original packages. However,\nto successfully compile and use these libraries, these source files have to be\nslightly modified. These modifications are stored as patches under the directory\n`patches`. The patches are automatically applied before compiling the different\ncomponents.\n\nThe changes applied by each patch are described in files named `changelog.txt`\nlocated under `CBLAS`, `CLAPACK-3.2.1`, `f2c_BLAS-3.8.0` and `libf2c`.\n\nFor a summary of what changed in these components, please read below.\n\n## Automatic FORTRAN 77 to C translation\n\n### f2c\n\n[`f2c`](https://www.netlib.org/f2c/) is a tool that converts FORTRAN to C code.\nTo account for the fact that FORTRAN `real` type is equivalent to C `float`\ntype, the `-R` flags has been systematically used.\n\nThe version of the program, which is not provided as it is not necessary is\n`20191129`.\n\n### libf2c\n\nAny code translated using the program `f2c` needs to be link against the\n`libf2c.a`library. This library can be created using the files in the directory\n`libf2c/`, which is provided in this repo.\n\nNote that the header file `f2c.h` in `libf2c` has been modified to account for\nthe fact that `int`s in modern C compilers are 4 bytes long. In short, the\nfollowing command has been run:\n\n```bash\nsed -i 's/long int /int /g' f2c.h\n```\n\nFor the complete list of changes made to libf2c, please refer to\n[./libf2c/changelog.txt](./libf2c/changelog.txt).\n\n### Automated translation of BLAS from FORTRAN to C\n\nBLAS, which is originally written in FORTRAN, has been tranlated to C using the\nprogram [`f2c`](https://www.netlib.org/f2c/) using the command\n\n```bash\nmkdir f2c_BLAS-3.8.0\nf2c -d f2c_BLAS-3.8.0 -aR *.c\n```\n\nin the BLAS (version 3.8.0) directory.\n\nThis produces C files in the directory `f2c_BLAS-3.8.0/`. Note that the files\n`xerbla.f` and `xerbla_array.f` cannot be translated to C with `f2c` as they\ncontain non FORTRAN 77 instructions. For these two files, the C source code has\nbeen taken from [`CLAPACK-3.2.1`](https://www.netlib.org/clapack/).\n\nAll other changes (mostly function signature changes) are listed in\n[f2c_BLAS-3.8.0/changelog.txt](f2c_BLAS-3.8.0/changelog.txt).\n\n## CBLAS\n\n### CBLAS changes\n\nThe original source code of CBLAS contains the following BLAS wrappers written\nin FORTRAN:\n\n```bash\ncdotcsub.f\ncdotusub.f\ndasumsub.f\nddotsub.f\ndnrm2sub.f\ndsdotsub.f\ndzasumsub.f\ndznrm2sub.f\nicamaxsub.f\nidamaxsub.f\nisamaxsub.f\nizamaxsub.f\nsasumsub.f\nscasumsub.f\nscnrm2sub.f\nsdotsub.f\nsdsdotsub.f\nsnrm2sub.f\nzdotcsub.f\nzdotusub.f\n```\n\nAs these were simple wrappers, their usage in the C code has been replaced\nby direct calls to the BLAS subroutines (provided by the BLAS library). The\nmodifications had to make the following assumptions:\n\n* BLAS to C type equivalence\n  * `REAL` -\u003e `float`\n  * `DOUBLEREAL` -\u003e `double`\n  * `INTEGER` -\u003e `int`\n  * `VOID` -\u003e `void`\n* `f2c` converted function interface\n  * The subroutines `cdotc`, `cdotu`, `zdotc`, and `zdotu` return no value but\n    store the result in a pointer given as a subroutine parameter\n* Complex types\n  * The then missing C types `complex` and `doublecomplex` have been defined\n    in `include/cblas_f77.h`\n\nWith these modifications, the FORTRAN free code of CBLAS passes all the\n(unmodified) tests in the `testing` directory.\n\nFor the complete list of changes, please refer to [CBLAS/changelog.txt](CBLAS/changelog.txt)\n\n### CBLAS test suite\n\nTo allow automated testing of the generated CBLAS library in wasm, the test\nsuites has also been converted to c using `f2c`. To ensure that the converted\ntests are correct, the following procedure has been followed:\n\n1. Convert BLAS to C and CBLAS to C **without modifying the test source code**\n2. Once CBLAS passes all the original tests, convert the test source code\n  **without modifying the CBLAS or BLAS C code**.\n3. Check that all the tests (now written in C) pass with the BLAS and CBLAS\n  code (written in C too)\n\n## CLAPACK\n\nUsage of the following functions had to be changed:\n* `xerbla_` (return value type)\n* `lsame_` (return value and argument list)\n* `s_copy` (return value type)\n* `s_cat` (return value type)\n\nFor the complete list of changes, please refer to\n[CLAPACK/changelog.txt](CLAPACK/changelog.txt)\n\nFor more information about CLAPACK and LAPACK, please refer to\n\n```\nAnderson, E.; Bai, Z.; Bischof, C.; Blackford, S.; Demmel, J.; Dongarra, J.;\nDu Croz, J.; Greenbaum, A.; Hammarling, S.; McKenney, A. \u0026 Sorensen, D.\nLAPACK Users' Guide\nSociety for Industrial and Applied Mathematics, 1999\n```\n\n## Linking against CLAPACK\n\nTo use the various libraries, assuming that the variable `CLAPACKROOT` contains\nthe path to the root of this directory, link as follows:\n\n```\n$(CLAPACKROOT)/CLAPACK-3.2.1/lapack.a $(CLAPACKROOT)/CLAPACK-3.2.1/libcblaswr.a \\\n$(CLAPACKROOT)/CBLAS/lib/cblas.a \\\n$(CLAPACKROOT)/f2c_BLAS-3.8.0/blas.a $(CLAPACKROOT)/libf2c/libf2c.a\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fccoreilly%2Fclapack-wasm","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fccoreilly%2Fclapack-wasm","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fccoreilly%2Fclapack-wasm/lists"}