Skip to content

Commit

Permalink
core library as submodule (#675)
Browse files Browse the repository at this point in the history
* git submodule added

* git submodule address fix

* disable branch

* testing wasm production

* testing

* testing

* submodule added

* better workflow

* cleaning

* cleaning

* cleaning
  • Loading branch information
grzanka authored Sep 14, 2021
1 parent 64b70a4 commit c2ac0a0
Show file tree
Hide file tree
Showing 28 changed files with 100 additions and 85,020 deletions.
98 changes: 95 additions & 3 deletions .github/workflows/node.js.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
build:

runs-on: ubuntu-latest

needs: [webasm_package]
strategy:
matrix:
node-version: [12.x, 14.x, 16.x]
Expand All @@ -33,13 +33,87 @@ jobs:
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'

- uses: actions/download-artifact@v2
with:
name: wasm files
path: src

- name: Display structure of downloaded files
run: ls -R
working-directory: src

- uses: actions/download-artifact@v2
with:
name: wasm files
path: src/static/js

- name: Display structure of downloaded files
run: ls -R
working-directory: src/static/js


- run: npm ci
- run: npm run build --if-present
# - run: npm test


webasm_package:
runs-on: ubuntu-latest
# needs: [build]
steps:
- uses: actions/checkout@v2
with:
submodules: recursive

- name: Test submodule checkout
run: |
ls -al
ls -al library
- uses: mymindstorm/setup-emsdk@v7

- name: Cache compiled GSL
uses: actions/cache@v2
env:
cache-name: cache-node-modules
with:
path: $HOME/usr
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/main.yml') }}
restore-keys: |
${{ runner.os }}-build-${{ env.cache-name }}-
${{ runner.os }}-build-
${{ runner.os }}-
- name: Compile GSL
run: |
wget -q "http://ftpmirror.gnu.org/gnu/gsl/gsl-latest.tar.gz"
mkdir $HOME/gsl-latest
tar -xzf gsl-latest.tar.gz -C $HOME/gsl-latest
mv $HOME/gsl-latest/** $HOME/gsl-latest/gsl
mkdir $HOME/usr
cd $HOME/gsl-latest/gsl/ && emconfigure ./configure --prefix=$HOME/usr --disable-shared && emmake make -j2 && emmake make install
ls -al $HOME/usr/lib/
- name: Compile libamtrack webassembly package
run: |
cp $HOME/usr/lib/libgsl.a library/distributions/JavaScript/
cp $HOME/usr/lib/libgslcblas.a library/distributions/JavaScript/
cd library/distributions/JavaScript && GSL_INCLUDE_DIRS=$HOME/usr/include GSL_LIBRARY=$HOME/usr/lib/libgsl.a GSL_CBLAS_LIBRARY=$HOME/usr/lib/libgslcblas.a ./compile_to_js.sh
- name: 'Upload Artifact'
uses: actions/upload-artifact@v2
with:
name: wasm files
path: |
library/distributions/JavaScript/output/libat.wasm
library/distributions/JavaScript/output/libat.js
if-no-files-found: error
retention-days: 5

test_and_deploy:
runs-on: ubuntu-latest
needs: [build]
needs: [build]
steps:
- name: Checkout 🛎️
uses: actions/checkout@v2
Expand All @@ -52,6 +126,24 @@ jobs:
- name: Install 🔧
run: npm install

- uses: actions/download-artifact@v2
with:
name: wasm files
path: src

- name: Display structure of downloaded files
run: ls -R
working-directory: src

- uses: actions/download-artifact@v2
with:
name: wasm files
path: src/static/js

- name: Display structure of downloaded files
run: ls -R
working-directory: src/static/js

- name: Adjust build info
run: |
sed -i '6s/web/web_dev/' package.json
Expand Down
4 changes: 4 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[submodule "library"]
path = library
url = https://github.com/libamtrack/library.git
shallow = true
1 change: 1 addition & 0 deletions library
Submodule library added at 6d8712
4 changes: 0 additions & 4 deletions src/functionsFromC/AT_CSDA_energy_after_slab_E_MeV_u_multi.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,5 @@ export default function AT_CSDA_energy_after_slab_E_MeV_u_multi(parameters) {
let result = at_csda_energy_after_slab_e_mev_u_multi(n, E_initial_MeV_uHeap, particle_noHeap, material_no, slab_thickness_m, E_final_MeV_uReturnHeap.byteOffset);
let resultFromArray = new Float64Array(E_final_MeV_uReturnHeap.buffer, E_final_MeV_uReturnHeap.byteOffset, E_final_MeV_uReturnData.length);

Module._free(E_initial_MeV_uHeap.byteOffset);
Module._free(particle_noHeap.byteOffset);
Module._free(E_final_MeV_uReturnHeap.byteOffset);

return [].slice.call(resultFromArray);
}
5 changes: 0 additions & 5 deletions src/functionsFromC/AT_CSDA_range_g_cm2_multi.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,5 @@ export default function AT_CSDA_range_g_cm2_multi(parameters) {
let result = at_csda_range_g_cm2_multi(n, E_initial_MeV_uHeap, E_final_MeV_uData, particle_noHeap, material_no, CSDA_range_g_cm2ReturnHeap.byteOffset);
let resultFromArray = new Float64Array(CSDA_range_g_cm2ReturnHeap.buffer, CSDA_range_g_cm2ReturnHeap.byteOffset, CSDA_range_g_cm2ReturnData.length);

Module._free(E_initial_MeV_uHeap.byteOffset);
Module._free(E_final_MeV_uHeap.byteOffset);
Module._free(particle_noHeap.byteOffset);
Module._free(CSDA_range_g_cm2ReturnHeap.byteOffset);

return [].slice.call(resultFromArray);
}
4 changes: 0 additions & 4 deletions src/functionsFromC/AT_D_RDD_Gy.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,5 @@ export default function AT_D_RDD_Gy(parameters) {
let result = at_d_rdd_gy(n, r_mHeap, E_MeV_u, particle_no, material_no, rdd_model, rdd_parameterHeap, er_model, stopping_power_source_no, D_RDD_GyReturnHeap.byteOffset);
let resultFromArray = new Float64Array(D_RDD_GyReturnHeap.buffer, D_RDD_GyReturnHeap.byteOffset, D_RDD_GyReturnData.length);

Module._free(r_mHeap.byteOffset);
Module._free(rdd_parameterHeap.byteOffset);
Module._free(D_RDD_GyReturnHeap.byteOffset);

return [].slice.call(resultFromArray);
}
3 changes: 0 additions & 3 deletions src/functionsFromC/AT_E_MeV_u_from_momentum_MeV_c_u.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,5 @@ export default function AT_E_MeV_u_from_momentum_MeV_c_u(parameters) {
let result = at_e_mev_u_from_momentum_mev_c_u(n, momentum_MeV_c_uHeap, E_MeV_uReturnHeap.byteOffset);
let resultFromArray = new Float64Array(E_MeV_uReturnHeap.buffer, E_MeV_uReturnHeap.byteOffset, E_MeV_uReturnData.length);

Module._free(momentum_MeV_c_uHeap.byteOffset);
Module._free(E_MeV_uReturnHeap.byteOffset);

return [].slice.call(resultFromArray);
}
3 changes: 0 additions & 3 deletions src/functionsFromC/AT_E_from_beta.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,5 @@ export default function AT_E_from_beta(parameters) {
let result = at_e_from_beta(n, betaHeap, E_MeV_uReturnHeap.byteOffset);
let resultFromArray = new Float64Array(E_MeV_uReturnHeap.buffer, E_MeV_uReturnHeap.byteOffset, E_MeV_uReturnData.length);

Module._free(betaHeap.byteOffset);
Module._free(E_MeV_uReturnHeap.byteOffset);

return [].slice.call(resultFromArray);
}
3 changes: 0 additions & 3 deletions src/functionsFromC/AT_E_from_gamma.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,5 @@ export default function AT_E_from_gamma(parameters) {
let result = at_e_from_gamma(n, gammaHeap, E_MeV_uReturnHeap.byteOffset);
let resultFromArray = new Float64Array(E_MeV_uReturnHeap.buffer, E_MeV_uReturnHeap.byteOffset, E_MeV_uReturnData.length);

Module._free(gammaHeap.byteOffset);
Module._free(E_MeV_uReturnHeap.byteOffset);

return [].slice.call(resultFromArray);
}
3 changes: 0 additions & 3 deletions src/functionsFromC/AT_LET_Wilkens_keV_um.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,5 @@ export default function AT_LET_Wilkens_keV_um(parameters) {
}
let resultFromArray = new Float64Array(LET_keV_umReturnHeap.buffer, LET_keV_umReturnHeap.byteOffset, LET_keV_umReturnData.length);

Module._free(z_cmHeap.byteOffset);
Module._free(LET_keV_umReturnHeap.byteOffset);

return [].slice.call(resultFromArray);
}
4 changes: 0 additions & 4 deletions src/functionsFromC/AT_Mass_Stopping_Power_with_no.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,5 @@ export default function AT_Mass_Stopping_Power_with_no(parameters) {
let result = at_mass_stopping_power_with_no(stopping_power_source_no, n, E_MeV_uHeap, particle_noHeap, material_no, stopping_power_MeV_cm2_gReturnHeap.byteOffset);
let resultFromArray = new Float64Array(stopping_power_MeV_cm2_gReturnHeap.buffer, stopping_power_MeV_cm2_gReturnHeap.byteOffset, stopping_power_MeV_cm2_gReturnData.length);

Module._free(E_MeV_uHeap.byteOffset);
Module._free(particle_noHeap.byteOffset);
Module._free(stopping_power_MeV_cm2_gReturnHeap.byteOffset);

return [].slice.call(resultFromArray);
}
3 changes: 0 additions & 3 deletions src/functionsFromC/AT_RBE_proton.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,5 @@ export default function AT_RBE_proton(parameters) {
let result = at_proton_rbe_multi(n, z_cmHeap, entrance_dose_Gy, E_MeV, sigma_E_MeV, eps, ref_alpha_beta_ratio, rbe_model_no, rbeReturnHeap.byteOffset);
let resultFromArray = new Float64Array(rbeReturnHeap.buffer, rbeReturnHeap.byteOffset, rbeReturnData.length);

Module._free(z_cmHeap.byteOffset);
Module._free(rbeReturnHeap.byteOffset);

return [].slice.call(resultFromArray);
}
4 changes: 0 additions & 4 deletions src/functionsFromC/AT_Stopping_Power_with_no.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,5 @@ export default function AT_Stopping_Power_with_no(parameters) {
let result = at_stopping_power_with_no(stopping_power_source_no, n, E_MeV_uHeap, particle_noHeap, material_no, stopping_power_keV_umReturnHeap.byteOffset);
let resultFromArray = new Float64Array(stopping_power_keV_umReturnHeap.buffer, stopping_power_keV_umReturnHeap.byteOffset, stopping_power_keV_umReturnData.length);

Module._free(E_MeV_uHeap.byteOffset);
Module._free(particle_noHeap.byteOffset);
Module._free(stopping_power_keV_umReturnHeap.byteOffset);

return [].slice.call(resultFromArray);
}
3 changes: 0 additions & 3 deletions src/functionsFromC/AT_beta_from_E.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,5 @@ export default function AT_beta_from_E(parameters) {
let result = at_beta_from_e(n, E_MeV_uHeap, betaReturnHeap.byteOffset);
let resultFromArray = new Float64Array(betaReturnHeap.buffer, betaReturnHeap.byteOffset, betaReturnData.length);

Module._free(E_MeV_uHeap.byteOffset);
Module._free(betaReturnHeap.byteOffset);

return [].slice.call(resultFromArray);
}
4 changes: 0 additions & 4 deletions src/functionsFromC/AT_biological_dose_proton.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,5 @@ export default function AT_biological_dose_proton(parameters) {
resultFromArray[i] *= doseFromArray[i];
}

Module._free(z_cmHeap.byteOffset);
Module._free(rbeReturnHeap.byteOffset);
Module._free(dose_GyReturnHeap.byteOffset);

return [].slice.call(resultFromArray);
}
5 changes: 0 additions & 5 deletions src/functionsFromC/AT_dose_Gy_from_fluence_cm2.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,5 @@ export default function AT_dose_Gy_from_fluence_cm2(parameters) {
let result = at_dose_gy_from_fluence_cm2(n, E_MeV_uHeap, particle_noHeap, fluence_cm2Heap, material_no, stopping_power_source_no, dose_GyReturnHeap.byteOffset);
let resultFromArray = new Float64Array(dose_GyReturnHeap.buffer, dose_GyReturnHeap.byteOffset, dose_GyReturnData.length);

Module._free(E_MeV_uHeap.byteOffset);
Module._free(particle_noHeap.byteOffset);
Module._free(fluence_cm2Heap.byteOffset);
Module._free(dose_GyReturnHeap.byteOffset);

return [].slice.call(resultFromArray);
}
4 changes: 0 additions & 4 deletions src/functionsFromC/AT_effective_charge_from_E_MeV_u.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,5 @@ export default function AT_effective_charge_from_E_MeV_u(parameters) {
let result = at_effective_charge_from_e_mev_u(n, E_MeV_uHeap, particle_noHeap, effective_chargeReturnHeap.byteOffset);
let resultFromArray = new Float64Array(effective_chargeReturnHeap.buffer, effective_chargeReturnHeap.byteOffset, effective_chargeReturnData.length);

Module._free(E_MeV_uHeap.byteOffset);
Module._free(particle_noHeap.byteOffset);
Module._free(effective_chargeReturnHeap.byteOffset);

return [].slice.call(resultFromArray);
}
4 changes: 0 additions & 4 deletions src/functionsFromC/AT_effective_charge_from_beta.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,5 @@ export default function AT_effective_charge_from_beta(parameters) {
let result = at_effective_charge_from_beta(n, betaHeap, ZHeap, effective_chargeReturnHeap.byteOffset);
let resultFromArray = new Float64Array(effective_chargeReturnHeap.buffer, effective_chargeReturnHeap.byteOffset, effective_chargeReturnData.length);

Module._free(betaHeap.byteOffset);
Module._free(ZHeap.byteOffset);
Module._free(effective_chargeReturnHeap.byteOffset);

return [].slice.call(resultFromArray);
}
3 changes: 0 additions & 3 deletions src/functionsFromC/AT_energy_loss_distributions.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,5 @@ export default function AT_energy_loss_distributions(parameters) {

let resultFromArray = new Float64Array(fDdDReturnHeap.buffer, fDdDReturnHeap.byteOffset, fDdDReturnData.length);

Module._free(energy_loss_keVHeap.byteOffset);
Module._free(fDdDReturnHeap.byteOffset);

return [].slice.call(resultFromArray);
}
4 changes: 0 additions & 4 deletions src/functionsFromC/AT_energy_straggling_MeV2_cm2_g.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,5 @@ export default function AT_energy_straggling_MeV2_cm2_g(parameters) {
let result = at_energy_straggling_mev2_cm2_g(n, E_MeV_uHeap, particle_noHeap, material_no, dsE2dz_MeV2_cm2_gReturnHeap.byteOffset);
let resultFromArray = new Float64Array(dsE2dz_MeV2_cm2_gReturnHeap.buffer, dsE2dz_MeV2_cm2_gReturnHeap.byteOffset, dsE2dz_MeV2_cm2_gReturnData.length);

Module._free(E_MeV_uHeap.byteOffset);
Module._free(particle_noHeap.byteOffset);
Module._free(dsE2dz_MeV2_cm2_gReturnHeap.byteOffset);

return [].slice.call(resultFromArray);
}
3 changes: 0 additions & 3 deletions src/functionsFromC/AT_gamma_from_E.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,5 @@ export default function AT_gamma_from_E(parameters) {
let result = at_gamma_from_e(n, E_MeV_uHeap, gammaReturnHeap.byteOffset);
let resultFromArray = new Float64Array(gammaReturnHeap.buffer, gammaReturnHeap.byteOffset, gammaReturnData.length);

Module._free(E_MeV_uHeap.byteOffset);
Module._free(gammaReturnHeap.byteOffset);

return [].slice.call(resultFromArray);
}
5 changes: 0 additions & 5 deletions src/functionsFromC/AT_inactivation_cross_section_Katz_um2.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,10 +102,5 @@ export default function AT_KatzModel_inactivation_cross_section_m2(parameters) {
resultFromArray[i] *= 1e6 * 1e6; // m2 -> um2
}

Module._free(E_MeV_uHeap.byteOffset);
Module._free(rdd_parametersHeap.byteOffset);
Module._free(gamma_parametersHeap.byteOffset);
Module._free(inactivation_cross_section_m2ReturnHeap.byteOffset);

return [].slice.call(resultFromArray);
}
3 changes: 0 additions & 3 deletions src/functionsFromC/AT_max_electron_ranges_m.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,5 @@ export default function AT_max_electron_ranges_m(parameters) {
let result = at_max_electron_ranges_m(number_of_particles, E_MeV_uHeap, material_no, er_model, max_electron_range_mReturnHeap.byteOffset);
let resultFromArray = (new Float64Array(max_electron_range_mReturnHeap.buffer, max_electron_range_mReturnHeap.byteOffset, max_electron_range_mReturnData.length)).map(function(x) { return x * 1e6; });;

Module._free(E_MeV_uHeap.byteOffset);
Module._free(max_electron_range_mReturnHeap.byteOffset);

return [].slice.call(resultFromArray);
}
3 changes: 0 additions & 3 deletions src/functionsFromC/AT_momentum_MeV_c_u_from_E_MeV_u.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,5 @@ export default function AT_momentum_MeV_c_u_from_E_MeV_u(parameters) {
let result = at_momentum_mev_c_u_from_e_mev_u(n, E_MeV_uHeap, momentum_MeV_cReturnHeap.byteOffset);
let resultFromArray = new Float64Array(momentum_MeV_cReturnHeap.buffer, momentum_MeV_cReturnHeap.byteOffset, momentum_MeV_cReturnData.length);

Module._free(E_MeV_uHeap.byteOffset);
Module._free(momentum_MeV_cReturnHeap.byteOffset);

return [].slice.call(resultFromArray);
}
Binary file removed src/libat.wasm
Binary file not shown.
Loading

0 comments on commit c2ac0a0

Please sign in to comment.