diff --git a/apps/CMakeLists.txt b/apps/CMakeLists.txt index bb86f5c2103998ffebd04fb583866f824fd08a75..5d706823bb843e5155b3225579df6a6ae19a4fd3 100644 --- a/apps/CMakeLists.txt +++ b/apps/CMakeLists.txt @@ -22,6 +22,8 @@ else () add_subdirectory ( tutorials EXCLUDE_FROM_ALL ) endif() +add_subdirectory ( anydsl ) + # Python module if ( WALBERLA_BUILD_WITH_PYTHON ) diff --git a/apps/anydsl/CMakeLists.txt b/apps/anydsl/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..217f3d2be64d4faf18c4c1773476e324d724c203 --- /dev/null +++ b/apps/anydsl/CMakeLists.txt @@ -0,0 +1,18 @@ +cmake_minimum_required(VERSION 3.1 FATAL_ERROR) +find_package(AnyDSL-runtime REQUIRED) +include(${ANYDSL_RUNTIME_CMAKE_DIR}/Runtime.cmake) +include_directories(${ANYDSL_RUNTIME_DIR}/src) + +set(CLANG_FLAGS -O3 -march=native) +set(IMPALA_FLAGS --log-level info) + + +# examples based on the "mapping" +anydsl_runtime_wrap(IMPALA_OBJECT_FILE + CLANG_FLAGS ${CLANG_FLAGS} + IMPALA_FLAGS ${IMPALA_FLAGS} + FILES anydsl-md/impala/intrinsics/intrinsics_cpu.impala anydsl-md/impala/common.impala anydsl-md/impala/datastructures/linked_cell/cpu.impala anydsl-md/impala/utilities/linked_cell/cpu.impala anydsl-md/impala/algorithm/linked_cell/cpu.impala anydsl-md/impala/initialization/test.impala anydsl-md/impala/potential/lennard_jones.impala anydsl-md/impala/integration/verlet.impala anydsl-md/impala/boundary/rigid_walls.impala anydsl-md/impala/time_integration/cpu.impala anydsl-md/impala/run/cpu.impala) + +waLBerla_add_executable ( NAME md_simulation + FILES md_simulation.cpp ${IMPALA_OBJECT_FILE} anydsl-md/impala/clib/fileIO.c anydsl-md/impala/clib/allocate.c + DEPENDS core blockforest pe domain_decomposition vtk) diff --git a/apps/impala/md_simulation.cpp b/apps/anydsl/md_simulation.cpp similarity index 100% rename from apps/impala/md_simulation.cpp rename to apps/anydsl/md_simulation.cpp diff --git a/apps/impala/CMakeLists.txt b/apps/impala/CMakeLists.txt deleted file mode 100644 index d7585acd5991345931dd0005f3862995473e9504..0000000000000000000000000000000000000000 --- a/apps/impala/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -cmake_minimum_required(VERSION 3.1 FATAL_ERROR) -find_package(AnyDSL-runtime REQUIRED) -include(${ANYDSL_RUNTIME_CMAKE_DIR}/Runtime.cmake) -include_directories(${ANYDSL_RUNTIME_DIR}/src) - -set(CLANG_FLAGS -O3 -march=native) -set(IMPALA_FLAGS --log-level info) - -# examples based on the "mapping" -anydsl_runtime_wrap(IMPALA_OBJECT_FILE - CLANG_FLAGS ${CLANG_FLAGS} - IMPALA_FLAGS ${IMPALA_FLAGS} - FILES intrinsics/intrinsics_cpu.impala common.impala datastructures/linked_cell/cpu.impala utilities/linked_cell/cpu.impala algorithm/linked_cell/cpu.impala initialization/test.impala potential/lennard_jones.impala integration/verlet.impala boundary/rigid_walls.impala time_integration/cpu.impala run/cpu.impala) - -waLBerla_add_executable ( NAME md_simulation - FILES md_simulation.cpp ${IMPALA_OBJECT_FILE} clib/fileIO.c clib/allocate.c - DEPENDS core blockforest pe domain_decomposition vtk) diff --git a/apps/impala/ConfinedGas b/apps/impala/ConfinedGas deleted file mode 100755 index 43b9173973cd66a3c791c2a78ddec0968d39050f..0000000000000000000000000000000000000000 Binary files a/apps/impala/ConfinedGas and /dev/null differ diff --git a/apps/impala/algorithm/array/cpu.impala b/apps/impala/algorithm/array/cpu.impala deleted file mode 100644 index 13636907908782af7291ec477ab3bcbd156a1821..0000000000000000000000000000000000000000 --- a/apps/impala/algorithm/array/cpu.impala +++ /dev/null @@ -1,176 +0,0 @@ - -fn compute_force(P: ParticleSystem, force: fn(Particle, Particle, Constants) -> ()) -> () -{ - let start = 0 as size_t; - let lut = P.lut(); - for i in par_loop(start, P.np()) { - let p = P.getParticle(i); - p.setForces(get_null_vector()); - } - /* - initialize(lut.data, lut.rows()*lut.cols()*sizeof[u8]() as size_t, 0i32); - - for i in par_loop(start, P.np()){ - for j in loop(start, P.np()) { - if(i != j) - { - let mut row = i; - let mut col = j; - if (i > j) { - row = j; - col = i; - } - - if(row >= lut.rows()) { - let tmp = col; - col = row; - row = tmp; - col -= lut.rows(); - row -= lut.rows(); - - } - let flag = cmpxchg(&mut bitcast[&mut[u8]](lut.data)(row*lut.cols() + col), 0u8, 1u8); - if (flag(1) == true) - { - force(P.getParticle(i), P.getParticle(j), P.constants()); - } - } - } - }*/ - - for i in loop(start, P.np()) { - for j in loop(i+(1 as size_t), P.np()) { - let p1 = P.getParticle(i); - let p2 = P.getParticle(j); - force(p1, p2, P.constants()); - } - } -} - -fn update(P: ParticleSystem, dt: real, f: fn(Particle, real) -> ()) -> () { - for i in loop(0 as size_t, P.np()) { - f(P.getParticle(i), dt); - } -} - -fn move_particles(P: ParticleSystem) -> () { - for i in loop(0 as size_t, P.np()) { - boundary(P.getParticle(i), P.l()); - } -} - - -fn fprint_particle_system(fname: &[u8], step: size_t, P: ParticleSystem) -> () -{ - let start = 0 as size_t; - let fp = open_file(fname); - let N = P.np(); - - fprint_line(fp, "# vtk DataFile Version 2.0"); - fprint_string(fp, "Step "); - fprint_size_t(fp, step); - fprint_line(fp, " data"); - fprint_line(fp, "ASCII"); - fprint_line(fp, "DATASET UNSTRUCTURED_GRID"); - fprint_string(fp, "POINTS "); - fprint_size_t(fp, N); - fprint_line(fp, " double"); - loop(start, N, |i| { - let p = P.getParticle(i); - p.getCoordinates().fprint(fp); - fprint_string(fp, "\n"); - }); - fprint_string(fp, "\n\n"); - fprint_string(fp, "CELLS "); - fprint_size_t(fp, N); - fprint_string(fp, " "); - fprint_size_t(fp, (2 as size_t)*N); - - fprint_string(fp, "\n"); - loop(start, N, |i| { - fprint_string(fp, "1 "); - fprint_size_t(fp, i); - fprint_string(fp, "\n"); - }); - fprint_string(fp, "\n\n"); - - - fprint_string(fp, "CELL_TYPES "); - fprint_size_t(fp, N); - fprint_string(fp, "\n"); - loop(start, N, |i| { - fprint_string(fp, "1"); - fprint_string(fp, "\n"); - }); - - fprint_string(fp, "\n\n"); - - - fprint_string(fp, "POINT_DATA "); - fprint_size_t(fp, N); - fprint_string(fp, "\n"); - @loop(start, DIM, |d| { - fprint_string(fp, "SCALARS velocity_dim_"); - fprint_size_t(fp, d); - fprint_line(fp, " double"); - fprint_line(fp, "LOOKUP_TABLE default"); - $loop(start, N, |i| { - - let p = P.getParticle(i); - let v = p.getVelocities(); - let x = v.x(); - fprint_double(fp, x(d)); - fprint_string(fp, "\n"); - }); - fprint_string(fp, "\n"); - }); - - @loop(start, DIM, |d| { - fprint_string(fp, "SCALARS force_dim_"); - fprint_size_t(fp, d); - fprint_line(fp, " double"); - fprint_line(fp, "LOOKUP_TABLE default"); - $loop(start, N, |i| { - - let p = P.getParticle(i); - let v = p.getForces(); - let x = v.x(); - fprint_double(fp, x(d)); - fprint_string(fp, "\n"); - }); - fprint_string(fp, "\n"); - }); - - - fprint_string(fp, "SCALARS mass"); - fprint_line(fp, " double"); - fprint_line(fp, "LOOKUP_TABLE default"); - loop(start, N, |i| { - let p = P.getParticle(i); - let m = p.getMass(); - fprint_double(fp, m); - fprint_string(fp, "\n"); - }); - fprint_string(fp, "\n"); - - - close_file(fp); -} - - -fn print_statistics(P: ParticleSystem, t: real) -> () -{ - - let sqr = |x : real| {x*x}; - let mut e : real = 0.0; - loop(0 as size_t, P.np(), |i| { - let p = P.getParticle(i); - let v = p.getVelocities().reduce(sqr, |x,y|{x+y}, 0.0); - e += 0.5 * p.getMass() * v; - }); - print_string("t: "); - print_double(t); - print_string("\tE: "); - print_double(e); - print_char('\n'); -} diff --git a/apps/impala/algorithm/linked_cell/cpu.impala b/apps/impala/algorithm/linked_cell/cpu.impala deleted file mode 100644 index 3658a4682f9fa35e0bd3e31e45cc5ced87a7d6b5..0000000000000000000000000000000000000000 --- a/apps/impala/algorithm/linked_cell/cpu.impala +++ /dev/null @@ -1,259 +0,0 @@ - -fn compute_force(P: ParticleSystem, force: fn(Particle, Particle, Constants) -> ()) -> () -{ - let z = 0 as size_t; - let ic_start = [z,z,z]; - let ic_end = P.nc(); - for ic, pl1 in @iterate_over_particle_system(ic_start, ic_end, P) { - let p1 = get_particle_from_node(*pl1); - p1.setForces(get_null_vector()); - } - for ic, pl1 in @iterate_over_particle_system(ic_start, ic_end, P) { - let p1 = get_particle_from_node(*pl1); - let jc_start = [if(ic(0) > z) {ic(0) - 1 as size_t} else {ic(0)}, - if(ic(1) > z) {ic(1) - 1 as size_t} else{ic(1)}, - if(ic(2) > z) {ic(2) - 1 as size_t} else {ic(2)}]; - let jc_end = [if(ic(0) + 1 as size_t < ic_end(0)) {ic(0) + 2 as size_t} else {ic_end(0)}, - if(ic(1) + 1 as size_t < ic_end(1)) {ic(1) + 2 as size_t} else {ic_end(1)}, - if(ic(2) + 1 as size_t < ic_end(2)) {ic(2) + 2 as size_t} else {ic_end(2)}]; - for jc, pl2 in iterate_over_particle_system(jc_start, jc_end, P) { - if((pl1 as ptr_t < pl2 as ptr_t)) { - let p2 = get_particle_from_node(*pl2); - force(p1, p2, P.constants()); - } - } - } -} - -fn update(P: ParticleSystem, dt: real, f: fn(Particle, real) -> ()) -> () -{ - let z = 0 as size_t; - let ic_start = [z,z,z]; - let ic_end = P.nc(); - for ic, pl in @iterate_over_particle_system(ic_start, ic_end, P) { - let p = get_particle_from_node(*pl); - f(p, dt); - } -} - -fn move_particles(P: ParticleSystem) -> () { - let z = 0 as size_t; - let ic_start = [z,z,z]; - let ic_end = P.nc(); - for ic, root in @iterate_over_particle_cells(ic_start, ic_end, P) { - let mut q : &mut &ParticleList = root; - let mut i : &ParticleList = *q; - - while(i != 0 as &ParticleList) { - let p = get_particle_from_node(*i); - boundary(p, P.l()); - let kc = compute_cell_position(p, P.nc(), P.l()); - let mut moving_node : &mut ParticleList; - if(ic(0) != kc(0) || ic(1) != kc(1) || ic(2) != kc(2)) { - moving_node = remove(q); - insert(P.head(index(kc, P.nc())), moving_node); - } - else { - q = (&(*i).next) as &mut& ParticleList; - } - i = (*q); - } - } - -} -fn fprint_particle_system(fname: &[u8], step: size_t, P: ParticleSystem) -> () -{ - let start = 0 as size_t; - let fp = open_file(fname); - let N = P.np(); - - fprint_line(fp, "# vtk DataFile Version 2.0"); - fprint_string(fp, "Step "); - fprint_size_t(fp, step); - fprint_line(fp, " data"); - fprint_line(fp, "ASCII"); - fprint_line(fp, "DATASET UNSTRUCTURED_GRID"); - fprint_string(fp, "POINTS "); - fprint_size_t(fp, N); - fprint_line(fp, " double"); - - let addresses = P.addresses(); - - for i in loop(start, N) { - let p = get_particle(addresses.get(i)); - p.getCoordinates().fprint(fp); - fprint_string(fp, "\n"); - } - fprint_string(fp, "\n\n"); - fprint_string(fp, "CELLS "); - fprint_size_t(fp, N); - fprint_string(fp, " "); - fprint_size_t(fp, (2 as size_t)*N); - - fprint_string(fp, "\n"); - for i in loop(start, N){ - fprint_string(fp, "1 "); - fprint_size_t(fp, i); - fprint_string(fp, "\n"); - } - fprint_string(fp, "\n\n"); - - - fprint_string(fp, "CELL_TYPES "); - fprint_size_t(fp, N); - fprint_string(fp, "\n"); - for i in loop(start, N) { - fprint_string(fp, "1"); - fprint_string(fp, "\n"); - } - - fprint_string(fp, "\n\n"); - - - fprint_string(fp, "POINT_DATA "); - fprint_size_t(fp, N); - fprint_string(fp, "\n"); - for d in loop(start, DIM) { - fprint_string(fp, "SCALARS velocity_dim_"); - fprint_size_t(fp, d); - fprint_line(fp, " double"); - fprint_line(fp, "LOOKUP_TABLE default"); - for i in loop(start, N) { - let p = get_particle(addresses.get(i)); - let v = p.getVelocities(); - let x = v.x(); - fprint_double(fp, x(d)); - fprint_string(fp, "\n"); - } - fprint_string(fp, "\n"); - } - for d in loop(start, DIM) { - fprint_string(fp, "SCALARS force_dim_"); - fprint_size_t(fp, d); - fprint_line(fp, " double"); - fprint_line(fp, "LOOKUP_TABLE default"); - for i in loop(start, N) { - let p = get_particle(addresses.get(i)); - let v = p.getForces(); - let x = v.x(); - fprint_double(fp, x(d)); - fprint_string(fp, "\n"); - } - fprint_string(fp, "\n"); - } - - fprint_string(fp, "SCALARS mass"); - fprint_line(fp, " double"); - fprint_line(fp, "LOOKUP_TABLE default"); - for i in loop(start, N) { - let p = get_particle(addresses.get(i)); - let m = p.getMass(); - fprint_double(fp, m); - fprint_string(fp, "\n"); - } - fprint_string(fp, "\n"); - close_file(fp); -} - -/* -fn fprint_particle_system(fname: &[u8], step: size_t, P: ParticleSystem) -> () -{ - let start = 0 as size_t; - let fp = open_file(fname); - let N = P.np(); - - let z = 0 as size_t; - let ic_start = [z,z,z]; - let ic_end = P.nc(); - - fprint_line(fp, "# vtk DataFile Version 2.0"); - fprint_string(fp, "Step "); - fprint_size_t(fp, step); - fprint_line(fp, " data"); - fprint_line(fp, "ASCII"); - fprint_line(fp, "DATASET UNSTRUCTURED_GRID"); - fprint_string(fp, "POINTS "); - fprint_size_t(fp, N); - fprint_line(fp, " double"); - - for ic, pl in iterate_over_particle_system(ic_start, ic_end, P) { - let p = get_particle_from_cell(*pl); - p.getCoordinates().fprint(fp); - fprint_string(fp, "\n"); - } - fprint_string(fp, "\n\n"); - fprint_string(fp, "CELLS "); - fprint_size_t(fp, N); - fprint_string(fp, " "); - fprint_size_t(fp, (2 as size_t)*N); - - fprint_string(fp, "\n"); - for i in loop(start, N){ - fprint_string(fp, "1 "); - fprint_size_t(fp, i); - fprint_string(fp, "\n"); - } - fprint_string(fp, "\n\n"); - - - fprint_string(fp, "CELL_TYPES "); - fprint_size_t(fp, N); - fprint_string(fp, "\n"); - for i in loop(start, N) { - fprint_string(fp, "1"); - fprint_string(fp, "\n"); - } - - fprint_string(fp, "\n\n"); - - - fprint_string(fp, "POINT_DATA "); - fprint_size_t(fp, N); - fprint_string(fp, "\n"); - for d in loop(start, DIM) { - fprint_string(fp, "SCALARS velocity_dim_"); - fprint_size_t(fp, d); - fprint_line(fp, " double"); - fprint_line(fp, "LOOKUP_TABLE default"); - for ic, pl in iterate_over_particle_system(ic_start, ic_end, P) { - let p = get_particle_from_cell(*pl); - let v = p.getVelocities(); - let x = v.x(); - fprint_double(fp, x(d)); - fprint_string(fp, "\n"); - } - fprint_string(fp, "\n"); - } - fprint_string(fp, "SCALARS mass"); - fprint_line(fp, " double"); - fprint_line(fp, "LOOKUP_TABLE default"); - for ic, pl in iterate_over_particle_system(ic_start, ic_end, P) { - let p = get_particle_from_cell(*pl); - let m = p.getMass(); - fprint_double(fp, m); - fprint_string(fp, "\n"); - } - fprint_string(fp, "\n"); - - - close_file(fp); - -} -*/ - -fn print_statistics(P: ParticleSystem, t: real) -> () -{ - - let sqr = |x : real| {x*x}; - let e : real = 0.0; - /* - loop(0 as size_t, P.np(), |i| { - let v = P.velocities().get(i).reduce(sqr, |x,y|{x+y}, 0.0); - e += 0.5 * P.masses().get(i) * v; - });*/ - print_string("t: "); - print_double(t); - print_string("\tE: "); - print_double(e); - print_char('\n'); -} diff --git a/apps/impala/boundary/rigid_walls.impala b/apps/impala/boundary/rigid_walls.impala deleted file mode 100644 index 4a4b1bcb8d4c9678ce8cf5abd42aebe195157c9f..0000000000000000000000000000000000000000 --- a/apps/impala/boundary/rigid_walls.impala +++ /dev/null @@ -1,17 +0,0 @@ -fn boundary(p: Particle, l: Vector) -> () { - let mut x = p.getCoordinates().x(); - let mut change = false; - for d in @loop(0 as size_t, DIM) { - if(x(d) < 0.0) { - x(d) = 0.0+EPS; - change = true; - } - else if(x(d) > l.x()(d)) { - x(d) = l.x()(d)-EPS; - change = true; - } - } - if(change == true) { - p.setCoordinates(get_vector(x)); - } -} diff --git a/apps/impala/clean_build b/apps/impala/clean_build deleted file mode 100755 index f88490d2b9b888caea1d763c6506c6d05bea77fa..0000000000000000000000000000000000000000 --- a/apps/impala/clean_build +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/sh -rm -rf Makefile CMakeFiles cmake_install.cmake CMakeCache.txt CTestTestfile.cmake *.o *.ll md diff --git a/apps/impala/clib/allocate.c b/apps/impala/clib/allocate.c deleted file mode 100644 index a0c456af62d88d1f42d40d9d2feed19874b9a223..0000000000000000000000000000000000000000 --- a/apps/impala/clib/allocate.c +++ /dev/null @@ -1,26 +0,0 @@ -#include <stdlib.h> -#include <string.h> - -static size_t ALIGNMENT = 64ul; -unsigned char * allocate(size_t size) { - return (unsigned char *)aligned_alloc(ALIGNMENT, size); -} - - -unsigned char * allocate_and_initialize(size_t size, int val) { - void *ptr = aligned_alloc(ALIGNMENT, size); - memset(ptr, val, size); - return (unsigned char *)ptr; -} - -unsigned char * reallocate(unsigned char *ptr, size_t size) { - return (unsigned char *)realloc((void *)ptr, size); -} - -void initialize(unsigned char * ptr, size_t size, int val) { - memset((void *)ptr, val, size); -} - -void deallocate(unsigned char *ptr) { - free(ptr); -} diff --git a/apps/impala/clib/allocate.h b/apps/impala/clib/allocate.h deleted file mode 100644 index a8a354e27b41db2985f105bdbbc4eb08a2467c03..0000000000000000000000000000000000000000 --- a/apps/impala/clib/allocate.h +++ /dev/null @@ -1,5 +0,0 @@ -unsigned char * allocate(size_t size); -unsigned char * allocate_and_initialize(size_t size, int val); -unsigned char * reallocate(unsigned char *ptr, size_t size); -void initialize(unsigned char *ptr, size_t size, int val); -void deallocate(unsigned char *ptr); diff --git a/apps/impala/clib/fileIO.c b/apps/impala/clib/fileIO.c deleted file mode 100644 index 880e14ee80b13d27b29305433e46a8c23e5dd177..0000000000000000000000000000000000000000 --- a/apps/impala/clib/fileIO.c +++ /dev/null @@ -1,55 +0,0 @@ -#include <stdio.h> -#include <stdint.h> - - - -void size_t_to_string(size_t i, unsigned char *buf, size_t bufsize) { - snprintf(buf, bufsize, "%lu", i); -} - -void generate_filename(size_t i, unsigned char *buf, size_t bufsize) { - snprintf(buf, bufsize, "../impala_vtk/particles%lu.vtk", i); -} - -uintptr_t open_file(unsigned char const *fname) { - FILE *fp = fopen(fname, "w"); - if(fp == NULL) { - fprintf(stderr, "open_file: Could not open file %s", fname); - perror(""); - return 0; - } - else { - return (uintptr_t)fp; - } -} -void close_file(uintptr_t fp) { - fclose((FILE *)fp); -} - -void fprint_string(uintptr_t fp, unsigned char const *str) { - fputs(str, (FILE *)fp); -} - -void fprint_line(uintptr_t fp, unsigned char const *str) { - fprintf((FILE *)fp, "%s\n", str); -} -void fprint_double(uintptr_t fp, double d) { - fprintf((FILE *)fp, "%f", d); -} - -void fprint_float(uintptr_t fp, float f) { - fprintf((FILE *)fp, "%f", f); -} - -void fprint_int(uintptr_t fp, int i) { - fprintf((FILE *)fp, "%d", i); -} - - -void fprint_size_t(uintptr_t fp, size_t i) { - fprintf((FILE *)fp, "%lu", i); -} - -void fprint_char(uintptr_t fp, unsigned char c) { - fputc((int)c, (FILE *)fp); -} diff --git a/apps/impala/clib/fileIO.h b/apps/impala/clib/fileIO.h deleted file mode 100644 index 23de9b3d181c1db079459b324992514274399b61..0000000000000000000000000000000000000000 --- a/apps/impala/clib/fileIO.h +++ /dev/null @@ -1,26 +0,0 @@ -#include <stdio.h> -#include <stdint.h> - - - -void size_t_to_string(size_t i, unsigned char *buf, size_t bufsize); - -void generate_filename(size_t i, unsigned char *buf, size_t bufsize); - -uintptr_t open_file(unsigned char const *fname); - -void close_file(uintptr_t fp); - -void fprint_string(uintptr_t fp, unsigned char const *str); - -void fprint_line(uintptr_t fp, unsigned char const *str); -void fprint_double(uintptr_t fp, double d); - -void fprint_float(uintptr_t fp, float f); - -void fprint_int(uintptr_t fp, int i); - -void fprint_size_t(uintptr_t fp, size_t i); - -void fprint_char(uintptr_t fp, unsigned char c); - diff --git a/apps/impala/common.impala b/apps/impala/common.impala deleted file mode 100644 index 9af5d594f7e281c310834ee801238288924a561d..0000000000000000000000000000000000000000 --- a/apps/impala/common.impala +++ /dev/null @@ -1,270 +0,0 @@ -extern "C" -{ - fn size_t_to_string(size_t, &mut[u8], size_t) -> (); - fn generate_filename(size_t , &mut[u8], size_t) -> (); - fn open_file(&[u8]) -> u64; - fn close_file(u64) -> (); - fn fprint_string(u64, &[u8]) -> (); - fn fprint_line(u64, &[u8]) -> (); - fn fprint_double(u64, f64) -> (); - fn fprint_float(u64, f32) -> (); - fn fprint_int(u64, i32) -> (); - fn fprint_size_t(u64, size_t) -> (); - fn fprint_char(u64, u8) -> (); - fn allocate(size_t) -> &u8; - fn allocate_and_initialize(size_t, i32) -> &u8; - fn initialize(&u8, size_t, i32) -> (); - fn deallocate(&u8) -> (); -} - -type size_t = u64; -type ptr_t = u64; -type real = f64; -static INF = 1e308f64; -static EPS = 1e-12; -static DIM = 3 as size_t; -static SIZEOFPARTICLE = ((1 as size_t) + (4 as size_t) * DIM) * (sizeof[real]() as size_t); - - -struct Vector -{ - x: fn() -> [real * 3], - append: fn(fn(real, real) -> real, Vector) -> Vector, - map: fn(fn(real) -> real) -> Vector, - reduce: fn(fn(real) -> real, fn(real, real) -> real, real) -> real, - print: fn() -> (), - fprint: fn(u64) -> () -} - -fn get_vector(x: [real * 3]) -> Vector -{ - Vector { - x: || {x}, - append: |f: fn(real, real) -> real, v: Vector| { - let mut res : [real * 3]; - let v_x = v.x(); - @loop((0 as size_t), DIM, |d| { - res(d) = f(x(d), v_x(d)); - }); - get_vector(res) - }, - map: |f: fn(real) -> real| { - let mut res : [real * 3]; - @loop(0 as size_t, DIM, |d| { - res(d) = f(x(d)); - }); - get_vector(res) - }, - reduce: |f: fn(real) -> real, g: fn(real, real) -> real, empty: real| { - let mut acc = empty; - @loop(0 as size_t, DIM, |d| { - acc = g(acc, f(x(d))); - }); - acc - }, - print: || { - @loop(0 as size_t, DIM-(1 as size_t), |d| { - print_double(x(d)); - print_char(' '); - }); - print_double(x(DIM-(1 as size_t))); - }, - fprint: |fp| { - @loop(0 as size_t, DIM-(1 as size_t), |d| { - fprint_double(fp, x(d)); - fprint_char(fp, ' '); - }); - fprint_double(fp, x(DIM-(1 as size_t))); - } - - } -} - -fn get_null_vector() -> Vector -{ - let mut res : [real * 3]; - @loop(0 as size_t, DIM, |d| { - res(d) = 0.0; - }); - get_vector(res) -} - -fn add_vectors(a: Vector, b: Vector) -> Vector { - a.append(|x,y|{x+y}, b) -} - -fn sub_vectors(a: Vector, b: Vector) -> Vector { - a.append(|x,y|{x-y}, b) -} - -fn scale_vector(alpha: real, v: Vector) -> Vector { - v.map(|x|{alpha*x}) -} - -struct Particle { - getMass: fn() -> real, - getCoordinates: fn() -> Vector, - getVelocities: fn() -> Vector, - getForces: fn() -> Vector, - getForces_old: fn() -> Vector, - setMass: fn(real) -> (), - setCoordinates: fn(Vector) -> (), - setVelocities: fn(Vector) -> (), - setForces: fn(Vector) -> (), - setForces_old: fn(Vector) -> () -} - -fn get_particle(data: &u8) -> Particle -{ - Particle { - getMass: || {bitcast[&[real]](data)(0)}, - getCoordinates: || { - let mut res : [real * 3]; - @loop(0 as size_t, DIM, |d| { - res(d) = bitcast[&[real]](data)((1 as size_t)+d); - }); - get_vector(res) - }, - getVelocities: || { - let mut res : [real * 3]; - @loop(0 as size_t, DIM, |d| { - res(d) = bitcast[&[real]](data)((1 as size_t)+DIM+d); - }); - get_vector(res) - }, - getForces: || { - let mut res : [real * 3]; - @loop(0 as size_t, DIM, |d| { - res(d) = bitcast[&[real]](data)((1 as size_t)+(2 as size_t)*DIM+d); - }); - get_vector(res) - }, - getForces_old: || { - let mut res : [real * 3]; - @loop(0 as size_t, DIM, |d| { - res(d) = bitcast[&[real]](data)((1 as size_t)+(3 as size_t)*DIM+d); - }); - get_vector(res) - }, - setMass: |m| {bitcast[&mut[real]](data)(0) = m;}, - setCoordinates: |v| { - let x = v.x(); - @loop(0 as size_t, DIM, |d| { - bitcast[&mut[real]](data)((1 as size_t)+d) = x(d); - }); - }, - setVelocities: |v| { - let x = v.x(); - @loop(0 as size_t, DIM, |d| { - bitcast[&mut[real]](data)((1 as size_t)+DIM+d) = x(d); - }); - }, - setForces: |v| { - let x = v.x(); - @loop(0 as size_t, DIM, |d| { - bitcast[&mut[real]](data)((1 as size_t)+(2 as size_t)*DIM+d) = x(d); - }); - }, - setForces_old: |v| { - let x = v.x(); - @loop(0 as size_t, DIM, |d| { - bitcast[&mut[real]](data)((1 as size_t)+(3 as size_t)*DIM+d) = x(d); - }); - } - } -} - -fn print_particle(p: Particle) -> () { - print_string("Particle\n"); - print_string("Mass: "); - print_double(p.getMass() as double); - print_string("\nCoordinates: "); - p.getCoordinates().print(); - print_string("\nVelocities: "); - p.getVelocities().print(); - print_string("\nForces: "); - p.getForces().print(); - print_string("\nForces_old: "); - p.getForces_old().print(); - print_char('\n'); -} - - -struct ParticleList { - data: &u8, - next: &ParticleList -} - -fn allocate_particle_node() -> &mut ParticleList { - let ptr = allocate(sizeof[ParticleList]() as size_t * sizeof[u8]() as size_t) as &mut ParticleList; - (*ptr).data = allocate(SIZEOFPARTICLE*(sizeof[u8]() as size_t)); - (*ptr).next = 0 as &ParticleList; - ptr -} - -fn deallocate_particle_node(ptr: &ParticleList) -> () { - deallocate((*ptr).data); - deallocate(ptr as &u8); -} - -fn get_particle_from_node(pl: &ParticleList) -> Particle { - get_particle((*pl).data) -} - -fn print_particle_node(pl: &ParticleList) -> () { - let p = get_particle_from_node(*pl); - print_string("ParticleList\n"); - print_long(pl as i64); - print_particle(p); -} - - -fn insert(root: &mut &ParticleList, pl: &mut ParticleList) -> () { - - //print_string("*root: "); - //print_long(*root as i64); - //print_char('\n'); - (*pl).next = *root; - *root = pl; -} - -fn remove(root: &mut &ParticleList) -> &mut ParticleList { - if(*root != 0 as &ParticleList) { - let retval : &mut ParticleList = *root; - *root = (**root).next; - retval - } - else { - 0 as &mut ParticleList - } -} - -fn delete_list(root: &mut &ParticleList) -> () { - let mut ptr = remove(root); - while(ptr != 0 as &mut ParticleList) - { - deallocate_particle_node(ptr); - ptr = remove(root); - } -} - - - - -fn loop(lower: size_t, upper: size_t, body: fn(size_t) -> ()) -> () { - if lower < upper { - body(lower); - loop(lower+(1 as size_t), upper, body, return) - } -} - -fn par_loop(lower: size_t, upper: size_t, body: fn(size_t) -> ()) -> () { - for i in parallel(@get_thread_count(), lower as i32, upper as i32) { - body(i as size_t); - } -} - -fn index(ic: [size_t * 3], nc: [size_t * 3]) -> size_t { - ic(0) + nc(0)*(ic(1) + nc(1)*ic(2)) -} - diff --git a/apps/impala/configure b/apps/impala/configure deleted file mode 100755 index 020b2177dbac0c4b8ce7c52bf3f35023538b73b1..0000000000000000000000000000000000000000 --- a/apps/impala/configure +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/sh -cmake . -DAnyDSL-runtime_DIR=/simdata/ja42rica/anydsl/runtime/ diff --git a/apps/impala/datastructures/array/cpu.impala b/apps/impala/datastructures/array/cpu.impala deleted file mode 100644 index 3a11663323c555638c81cafb8f5d88ed21cd032e..0000000000000000000000000000000000000000 --- a/apps/impala/datastructures/array/cpu.impala +++ /dev/null @@ -1,65 +0,0 @@ -struct ParticleSystem { - np: fn() -> size_t, - l: fn() -> Vector, - getParticle: fn(size_t) -> Particle, - lut: fn() -> LookupTable, - constants: fn() -> Constants, - data: fn() -> &u8 -} - -fn get_particle_system(np: size_t, l: Vector, data: &u8, lut: LookupTable, constants: Constants) -> ParticleSystem { - ParticleSystem { - np: || {np}, - l: || {l}, - getParticle: |i| {get_particle(&bitcast[&[u8]](data)(i*SIZEOFPARTICLE))}, - lut: || {lut}, - constants: || {constants}, - data: || {data} - } -} - -fn allocate_particle_system(np: size_t, l: Vector, constants: Constants) -> ParticleSystem { - let data = allocate(np * SIZEOFPARTICLE); - let lut = allocate_lookup_table(np); - get_particle_system(np, l, data, lut, constants) -} - -fn deallocate_particle_system(P: ParticleSystem) -> () { - deallocate(P.data()); - deallocate_lookup_table(P.lut()); -} - -fn insert_particle(node: &mut ParticleList, i: size_t, P: ParticleSystem) -> () { - let p = P.getParticle(i); - let p_new = get_particle_from_node(*node); - p.setMass(p_new.getMass()); - p.setCoordinates(p_new.getCoordinates()); - p.setVelocities(p_new.getVelocities()); - p.setForces(p_new.getForces()); - p.setForces_old(p_new.getForces_old()); - deallocate_particle_node(node); -} - - -struct LookupTable { - rows: fn() -> size_t, - cols: fn() -> size_t, - data: &u8 -} - -fn allocate_lookup_table(size: size_t) -> LookupTable { - LookupTable { - rows: || {size/2 as size_t + 0 as size_t}, - //rows: || {size}, - cols: || {size}, - data: {allocate((size * (size / 2 as size_t + 0 as size_t) * sizeof[u8]() as size_t))} - //data: {allocate(size * size)} - } -} - -fn deallocate_lookup_table(lut: LookupTable) -> () { - deallocate(lut.data); -} - - -fn init_addresses(P: ParticleSystem) -> () {} diff --git a/apps/impala/datastructures/array_cell/cpu.impala b/apps/impala/datastructures/array_cell/cpu.impala deleted file mode 100644 index 37cdcbb0a327058c3150fddfc6c9d61db250846f..0000000000000000000000000000000000000000 --- a/apps/impala/datastructures/array_cell/cpu.impala +++ /dev/null @@ -1,68 +0,0 @@ -struct Array -{ - get: fn(size_t) -> real, - set: fn(size_t, real) -> () -} - -fn get_array(data: &u8) -> Array -{ - Array - { - get: |i| { - bitcast[&[real]](data)(i) - }, - set: |i, r| { - bitcast[&mut[real]](data)(i) = r; - } - } - -} - -struct ParticleSystem -{ - - capacity_m: size_t, - capacity_X: [size_t * 3], - capacity_V: [size_t * 3], - capacity_F: [size_t * 3], - capacity_F_old: [size_t * 3], - np: fn() -> size_t, - nc: fn() -> [size_t * 3], - l: fn() -> Vector, - masses: fn(size_t) -> &mut &u8, - coordinates: fn(size_t) -> &mut [&u8 * 3], - velocities: fn(size_t) -> &mut [&u8 * 3], - forces: fn(size_t) -> &mut [&u8 * 3], - forces_old: fn(size_t) -> &mut [&u8 * 3], - data_coordinates: &u8, - data_velocities: &u8, - data_forces: &u8, - data_forces_old: &u8 -} - -fn get_particle_system(initial_capacity: size_t, np: size_t, nc: [size_t * 3], l: Vector, data_masses: &u8, data_coordinates: &u8, data_velocities: &u8, data_forces: &u8, data_forces_old: &u8, constants: Constants, data_addresses: &u8) -> ParticleSystem -{ - ParticleSystem - { - capacity_m: initial_capacity, - capacity_X: [initial_capacity, initial_capacity, initial_capacity], - capacity_V: [initial_capacity, initial_capacity, initial_capacity], - capacity_F: [initial_capacity, initial_capacity, initial_capacity], - capacity_F_old: [initial_capacity, initial_capacity, initial_capacity], - np: || {np}, - nc: || {nc}, - l: || {l}, - masses: |i| {&mut bitcast[&mut[&u8]](data_masses)(i)}, - coordinates: |i| {&mut bitcast[&mut[[&u8 * 3]]](data_coordinates)(i)}, - velocities: |i| {&mut bitcast[&mut[[&u8 * 3]]](data_velocities)(i)}, - forces: |i| {&mut bitcast[&mut[[&u8 * 3]]](data_forces)(i)}, - forces_old: |i| {&mut bitcast[&mut[[&u8 * 3]]](data_forces_old)(i)}, - constants: || {constants}, - addresses: || {get_array_of_addresses(np, data_addresses)}, - data_coordinates: || {data_coordinates}, - data_velocities: || {data_velocities}, - data_forces: || {data_forces}, - data_forces_old: || {data_forces}, - data_addresses: || {data_addresses} - } -} diff --git a/apps/impala/datastructures/linked_cell/cpu.impala b/apps/impala/datastructures/linked_cell/cpu.impala deleted file mode 100644 index 1f353b5c4bb6985ac57924aaa531a5a13b484b4d..0000000000000000000000000000000000000000 --- a/apps/impala/datastructures/linked_cell/cpu.impala +++ /dev/null @@ -1,139 +0,0 @@ -struct ParticleSystem { - np: fn() -> size_t, - nc: fn() -> [size_t * 3], - l: fn() -> Vector, - head: fn(size_t) -> &mut &ParticleList, - constants: fn() -> Constants, - addresses: fn() -> ArrayOfAddresses, - data_cells: fn() -> &u8, - data_addresses: fn() -> &u8 -} - -fn get_particle_system(np: size_t, nc: [size_t * 3], l: Vector, data_cells: &u8, constants: Constants, data_addresses: &u8) -> ParticleSystem -{ - ParticleSystem { - np: || {np}, - nc: || {nc}, - l: || {l}, - head: |i| {&mut bitcast[&mut[&ParticleList]](data_cells)(i)}, - constants: || {constants}, - addresses: || {get_array_of_addresses(np, data_addresses)}, - data_cells: || {data_cells}, - data_addresses: || {data_addresses} - } -} - -fn insert_particle(node: &mut ParticleList, i: size_t, P: ParticleSystem) -> () { - let p = get_particle_from_node(*node); - let kc = compute_cell_position(p, P.nc(), P.l()); - let root = P.head(index(kc, P.nc())); - insert(root, node); -} - -fn allocate_particle_system(np: size_t, l: Vector, constants: Constants) -> ParticleSystem { - let mut nc : [size_t * 3]; - let mut pnc = 1 as size_t; - for d in @loop(0 as size_t, DIM){ - nc(d) = math.floor(l.x()(d)/constants.r_cut) as size_t; - pnc *= nc(d); - } - let data_cells = allocate_and_initialize(pnc * sizeof[&ParticleList]() as size_t, 0); - let data_addresses = allocate(np * sizeof[&u8]() as size_t); - let P = get_particle_system(np, nc, l, data_cells, constants, data_addresses); - P -} - -fn deallocate_particle_system(P: ParticleSystem) -> () { - let z = 0 as size_t; - let start = [z,z,z]; - let end = P.nc(); - for i in loop(start(0), end(0)) { - for j in loop(start(1), end(1)) { - for k in loop(start(2), end(2)) { - let ic = [i,j,k]; - let head = P.head(index(ic, P.nc())); - delete_list(head); - } - } - } - deallocate(P.data_cells()); - deallocate(P.data_addresses()); -} -fn print_particle_system(P: ParticleSystem) -> (){ - - let z = 0 as size_t; - let start = [z,z,z]; - let end = P.nc(); - for i in loop(start(0), end(0)) { - for j in loop(start(1), end(1)) { - for k in loop(start(2), end(2)) { - let ic = [i,j,k]; - if(*P.head(index(ic, P.nc())) != 0 as &ParticleList) { - print_string("Cell ("); - print_long(i as i64); - print_string(", "); - print_long(j as i64); - print_string(", "); - print_long(k as i64); - print_string("): "); - print_string(" (Index: "); - print_long(index(ic, P.nc()) as i64); - print_string(" ) "); - for pl in iterate_over_list(*P.head(index(ic, P.nc()))) { - print_long(pl as i64); - print_char(' '); - } - print_char('\n'); - } - } - } - } -} - -fn compute_cell_position(p: Particle, nc: [size_t * 3], l: Vector) -> [size_t * 3] { - let mut kc : [size_t * 3]; - let coordinates_x = p.getCoordinates().x(); - let l_x = l.x(); - for d in @loop((0 as size_t), DIM) { - kc(d) = math.floor(coordinates_x(d) * (nc(d) as real) / l_x(d)) as size_t; - } - kc -} - - - -struct ArrayOfAddresses { - size: fn() -> size_t, - get: fn(size_t) -> &u8, - set: fn(size_t, &u8) -> () -} - -fn get_array_of_addresses(size: size_t, data: &u8) -> ArrayOfAddresses { - ArrayOfAddresses { - size: || {size}, - get: |i| {bitcast[&[&u8]](data)(i)}, - set: |i, ptr| { - bitcast[&mut[&u8]](data)(i) = ptr; - } - } -} - -fn init_addresses(P: ParticleSystem) -> () { - let mut pos = 0 as size_t; - let addresses = P.addresses(); - let z = 0 as size_t; - let start = [z,z,z]; - let end = P.nc(); - for ic, pl in iterate_over_particle_system(start, end, P) { - if(pl != 0 as &ParticleList) { - addresses.set(pos++, (*pl).data); - } - } -} - - - - - - - diff --git a/apps/impala/initialization/array/planets.impala b/apps/impala/initialization/array/planets.impala deleted file mode 100644 index d9d3d46a147f290105b91516b781d54b2541403e..0000000000000000000000000000000000000000 --- a/apps/impala/initialization/array/planets.impala +++ /dev/null @@ -1,32 +0,0 @@ -fn init_constants(constants: &mut Constants) -> () { - constants.r_cut = INF; -} - -fn init_particle_system(P: ParticleSystem) -> () { - if(P.np() != 4 as size_t) { - print_string("The number of particles must be 4\n"); - } - else { - let mut p : Particle; - let origin = get_vector([1000.0, 1000.0, 1000.0]); - p = P.getParticle(0 as size_t); - p.setMass(1.0); - p.setCoordinates(add_vectors(origin, get_vector([0.0, 0.0, 0.0]))); - p.setVelocities(get_vector([0.0, 0.0, 0.0])); - - p = P.getParticle(1 as size_t); - p.setMass(3e-6); - p.setCoordinates(add_vectors(origin, get_vector([0.0, 1.0, 0.0]))); - p.setVelocities(get_vector([-1.0, 0.0, 0.0])); - - p = P.getParticle(2 as size_t); - p.setMass(9.55e-4); - p.setCoordinates(add_vectors(origin, get_vector([0.0, 5.36, 0.0]))); - p.setVelocities(get_vector([-0.425, 0.0, 0.0])); - - p = P.getParticle(3 as size_t); - p.setMass(1e-14); - p.setCoordinates(add_vectors(origin, get_vector([34.75, 0.0, 0.0]))); - p.setVelocities(get_vector([0.0, 0.0296, 0.0])); - } -} diff --git a/apps/impala/initialization/linked_cell/planets.impala b/apps/impala/initialization/linked_cell/planets.impala deleted file mode 100644 index dc7407cce6c47b61314e63c807a3aff03eedaf6c..0000000000000000000000000000000000000000 --- a/apps/impala/initialization/linked_cell/planets.impala +++ /dev/null @@ -1,44 +0,0 @@ -fn init_constants(constants: &mut Constants) -> () { - constants.r_cut = INF; -} - -fn init_particle_system(P: ParticleSystem) -> () { - if(P.np() != 4 as size_t) { - print_string("The number of particles must be 4\n"); - } - else { - let mut p : Particle; - let sun = create_particle_cell(); - let earth = create_particle_cell(); - let jupiter = create_particle_cell(); - let halley = create_particle_cell(); - let root = P.head(0 as size_t); - - let origin = get_vector([1000.0, 1000.0, 1000.0]); - p = get_particle_from_cell(*sun); - p.setMass(1.0); - p.setCoordinates(add_vectors(origin, get_vector([0.0, 0.0, 0.0]))); - p.setVelocities(get_vector([0.0, 0.0, 0.0])); - insert(root, sun); - - p = get_particle_from_cell(*earth); - p.setMass(3e-6); - p.setCoordinates(add_vectors(origin, get_vector([0.0, 1.0, 0.0]))); - p.setVelocities(get_vector([-1.0, 0.0, 0.0])); - insert(root, earth); - - p = get_particle_from_cell(*jupiter); - p.setMass(9.55e-4); - p.setCoordinates(add_vectors(origin, get_vector([0.0, 5.36, 0.0]))); - p.setVelocities(get_vector([-0.425, 0.0, 0.0])); - insert(root, jupiter); - - p = get_particle_from_cell(*halley); - p.setMass(1e-14); - p.setCoordinates(add_vectors(origin, get_vector([34.75, 0.0, 0.0]))); - p.setVelocities(get_vector([0.0, 0.0296, 0.0])); - insert(root, halley); - - } -} - diff --git a/apps/impala/initialization/test.impala b/apps/impala/initialization/test.impala deleted file mode 100644 index b465ca8e96381b5a45f656c1db3b0ae46c5c0e41..0000000000000000000000000000000000000000 --- a/apps/impala/initialization/test.impala +++ /dev/null @@ -1,92 +0,0 @@ -fn init_constants(constants: &mut Constants) -> () { - constants.r_cut = 2.5; - constants.sigma = 1.0; - constants.epsilon = 5.0; -} - -fn init_particle_system(l: Vector, constants: Constants) -> ParticleSystem { - let mut limit1 : [size_t * 3]; - let mut limit2 : [size_t * 3]; - for d in @loop(0 as size_t, DIM) { - limit1(d) = 10 as size_t; - limit2(d) = 10 as size_t; - } - limit1(0) = 100 as size_t; - let mut np1 = 1 as size_t; - let mut np2 = 1 as size_t; - for d in @loop(0 as size_t, DIM) { - np1 *= limit1(d); - np2 *= limit2(d); - } - let P = allocate_particle_system(np1 + np2, l, constants); - - let factor = math.pow(2.0, 1.0/6.0)*P.constants().sigma; - let mut p : Particle; - let mut base : [real * 3]; - base(0) = 50.0; - base(1) = 100.0; - base(2) = 100.0; - let mut ip : [size_t * 3]; - for d in @loop(0 as size_t, DIM) { - ip(d) = 0 as size_t; - } - while(ip(0) < limit1(0)) { - while(ip(1) < limit1(1)) { - while(ip(2) < limit1(2)) { - let node = allocate_particle_node(); - p = get_particle_from_node(*node); - p.setMass(1.0); - p.setVelocities(get_null_vector()); - let mut X : [real * 3]; - for d in @loop(0 as size_t, DIM) { - X(d) = base(d) + ip(d) as real * factor; - } - p.setCoordinates(get_vector(X)); - let pos = ip(2)*limit1(0)*limit1(1) + ip(1)*limit1(1) + ip(0); - insert_particle(node, pos, P); - ++ip(2); - } - ++ip(1); - ip(2) = 0 as size_t; - } - ++ip(0); - ip(1) = 0 as size_t; - } - - - - base(0) = 100.0; - base(1) = 125.0; - base(2) = 100.0; - - for d in @loop(0 as size_t, DIM) { - ip(d) = 0 as size_t; - } - while(ip(0) < limit2(0)) { - while(ip(1) < limit2(1)) { - while(ip(2) < limit2(2)) { - let node = allocate_particle_node(); - p = get_particle_from_node(*node); - p.setMass(1.0); - p.setVelocities(get_vector([0.0, -300.0, 0.0])); - let mut X : [real * 3]; - - for d in @loop(0 as size_t, DIM) { - X(d) = base(d) + ip(d) as real * factor; - } - p.setCoordinates(get_vector(X)); - let pos = ip(2)*limit1(0)*limit1(1) + ip(1)*limit1(1) + ip(0); - insert_particle(node, pos, P); - ++ip(2); - } - ++ip(1); - ip(2) = 0 as size_t; - } - ++ip(0); - ip(1) = 0 as size_t; - } - - init_addresses(P); - P -} - diff --git a/apps/impala/integration/array/verlet.impala b/apps/impala/integration/array/verlet.impala deleted file mode 100644 index f2966e9d6b1790ed5735071153cad6808f6ee2e1..0000000000000000000000000000000000000000 --- a/apps/impala/integration/array/verlet.impala +++ /dev/null @@ -1,23 +0,0 @@ -fn integrate_x(P: ParticleSystem, i: size_t, dt: real) -> () -{ - let a = dt * 0.5 / P.masses().get(i); - let f = P.forces().get(i); - let tmp1 = scale_vector(a, f); - let v = P.velocities().get(i); - let tmp2 = add_vectors(v, tmp1); - let tmp3 = scale_vector(dt, tmp2); - let x = P.coordinates().get(i); - P.coordinates().set(i, add_vectors(x, tmp3)); - P.forces_old().set(i, f); -} - -fn integrate_v(P: ParticleSystem, i: size_t, dt: real) -> () -{ - let a = dt * 0.5 / P.masses().get(i); - let f = P.forces().get(i); - let f_old = P.forces_old().get(i); - let tmp1 = add_vectors(f, f_old); - let tmp2 = scale_vector(a, tmp1); - let v = P.velocities().get(i); - P.velocities().set(i, add_vectors(v, tmp2)); -} diff --git a/apps/impala/integration/verlet.impala b/apps/impala/integration/verlet.impala deleted file mode 100644 index 9faedd0e9e9f43ae1258429ea8d21183298823e0..0000000000000000000000000000000000000000 --- a/apps/impala/integration/verlet.impala +++ /dev/null @@ -1,28 +0,0 @@ -fn integrate_x(p: Particle, dt: real) -> () -{ - - //print_string("integrate_x\n"); - let a = dt * 0.5 / p.getMass(); - let f = p.getForces(); - let tmp1 = scale_vector(a, f); - let v = p.getVelocities(); - let tmp2 = add_vectors(v, tmp1); - let tmp3 = scale_vector(dt, tmp2); - let x = p.getCoordinates(); - p.setCoordinates(add_vectors(x, tmp3)); - p.setForces_old(f); - //print_string("integrate_x finished\n"); -} - -fn integrate_v(p: Particle, dt: real) -> () -{ - //print_string("integrate_v\n"); - let a = dt * 0.5 / p.getMass(); - let f = p.getForces(); - let f_old = p.getForces_old(); - let tmp1 = add_vectors(f, f_old); - let tmp2 = scale_vector(a, tmp1); - let v = p.getVelocities(); - p.setVelocities(add_vectors(v, tmp2)); - //print_string("integrate_v finished\n"); -} diff --git a/apps/impala/intrinsics/intrinsics_avx.impala b/apps/impala/intrinsics/intrinsics_avx.impala deleted file mode 100644 index 750e5a4fd0ca8c733f87a9e4b68bdfd830fa30b6..0000000000000000000000000000000000000000 --- a/apps/impala/intrinsics/intrinsics_avx.impala +++ /dev/null @@ -1,35 +0,0 @@ -static math = cpu_intrinsics; -fn is_nvvm() -> bool { false } -fn is_cuda() -> bool { false } -fn is_opencl() -> bool { false } -fn is_x86() -> bool { true } -fn is_sse() -> bool { true } -fn is_avx() -> bool { true } -fn is_avx2() -> bool { false } - -fn get_vector_length() -> int { 8 } -fn get_alignment() -> int { 32 } -fn get_thread_count() -> int { 4 } - -fn outer_loop(lower: int, upper: int, body: fn(int) -> ()) -> () { - for i in parallel(@get_thread_count(), lower, upper) { - body(i); - } -} -fn outer_loop_step(lower: int, upper: int, step: int, body: fn(int) -> ()) -> () { - for i in parallel(@get_thread_count(), 0, (upper-lower)/step) { - body(i * step + lower); - } -} -fn inner_loop(lower: int, upper: int, body: fn(int) -> ()) -> () { - // TODO: make sure lower and upper are a multiple of vector length - for i in vectorize(@get_vector_length(), @get_alignment(), lower, upper) { - body(i); - } -} -fn inner_loop_step(lower: int, upper: int, step: int, body: fn(int) -> ()) -> () { - // TODO: make sure lower and upper are a multiple of vector length - for i in vectorize(@get_vector_length(), @get_alignment(), 0, (upper-lower)/step) { - body(i * step + lower); - } -} diff --git a/apps/impala/intrinsics/intrinsics_cpu.impala b/apps/impala/intrinsics/intrinsics_cpu.impala deleted file mode 100644 index f1543e6e4b962b560e0593275caf0fa7a3ddaa35..0000000000000000000000000000000000000000 --- a/apps/impala/intrinsics/intrinsics_cpu.impala +++ /dev/null @@ -1,35 +0,0 @@ -static math = cpu_intrinsics; -fn is_nvvm() -> bool { false } -fn is_cuda() -> bool { false } -fn is_opencl() -> bool { false } -fn is_x86() -> bool { true } -fn is_sse() -> bool { false } -fn is_avx() -> bool { false } -fn is_avx2() -> bool { false } - -fn get_vector_length() -> int { 1 } -fn get_alignment() -> int { 4 } -fn get_thread_count() -> int { 4 } - -fn outer_loop(lower: int, upper: int, body: fn(int) -> ()) -> () { - for i in parallel(@get_thread_count(), lower, upper) { - body(i); - } -} -fn outer_loop_step(lower: int, upper: int, step: int, body: fn(int) -> ()) -> () { - for i in parallel(@get_thread_count(), 0, (upper-lower)/step) { - body(i * step + lower); - } -} -fn inner_loop(lower: int, upper: int, body: fn(int) -> ()) -> () { - if lower < upper { - body(lower); - inner_loop(lower+1, upper, body, return) - } -} -fn inner_loop_step(lower: int, upper: int, step: int, body: fn(int) -> ()) -> () { - if lower < upper { - body(lower); - inner_loop_step(lower+step, upper, step, body, return) - } -} diff --git a/apps/impala/intrinsics/intrinsics_cuda.impala b/apps/impala/intrinsics/intrinsics_cuda.impala deleted file mode 100644 index b306ee31a947239cc4257e3ff3cd608f0c0660f0..0000000000000000000000000000000000000000 --- a/apps/impala/intrinsics/intrinsics_cuda.impala +++ /dev/null @@ -1,13 +0,0 @@ -static acc = cuda_accelerator; -static math = cuda_intrinsics; -static atomic_add_global = cuda_atomic_add_global; -static atomic_add_shared = cuda_atomic_add_shared; -static atomic_min_global = cuda_atomic_min_global; -static atomic_min_shared = cuda_atomic_min_shared; -fn is_nvvm() -> bool { false } -fn is_cuda() -> bool { true } -fn is_opencl() -> bool { false } -fn is_x86() -> bool { false } -fn is_sse() -> bool { false } -fn is_avx() -> bool { false } -fn is_avx2() -> bool { false } diff --git a/apps/impala/intrinsics/intrinsics_nvvm.impala b/apps/impala/intrinsics/intrinsics_nvvm.impala deleted file mode 100644 index 16a72e3382cf348d52eff1ebf435635e1e3229f7..0000000000000000000000000000000000000000 --- a/apps/impala/intrinsics/intrinsics_nvvm.impala +++ /dev/null @@ -1,13 +0,0 @@ -static acc = nvvm_accelerator; -static math = nvvm_intrinsics; -static atomic_add_global = nvvm_atomic_add_global; -static atomic_add_shared = nvvm_atomic_add_shared; -static atomic_min_global = nvvm_atomic_min_global; -static atomic_min_shared = nvvm_atomic_min_shared; -fn is_nvvm() -> bool { true } -fn is_cuda() -> bool { false } -fn is_opencl() -> bool { false } -fn is_x86() -> bool { false } -fn is_sse() -> bool { false } -fn is_avx() -> bool { false } -fn is_avx2() -> bool { false } diff --git a/apps/impala/intrinsics/intrinsics_opencl.impala b/apps/impala/intrinsics/intrinsics_opencl.impala deleted file mode 100644 index 473b77b32abcb3121939699b5599ab7e08a0ad4d..0000000000000000000000000000000000000000 --- a/apps/impala/intrinsics/intrinsics_opencl.impala +++ /dev/null @@ -1,13 +0,0 @@ -static acc = opencl_accelerator; -static math = opencl_intrinsics; -static atomic_add_global = opencl_atomic_add_global; -static atomic_add_shared = opencl_atomic_add_shared; -static atomic_min_global = opencl_atomic_min_global; -static atomic_min_shared = opencl_atomic_min_shared; -fn is_nvvm() -> bool { false } -fn is_cuda() -> bool { false } -fn is_opencl() -> bool { true } -fn is_x86() -> bool { false } -fn is_sse() -> bool { false } -fn is_avx() -> bool { false } -fn is_avx2() -> bool { false } diff --git a/apps/impala/main.c b/apps/impala/main.c deleted file mode 100644 index 71b503d2637856ed2a7fcc1d93fa0632a9f9ebc4..0000000000000000000000000000000000000000 --- a/apps/impala/main.c +++ /dev/null @@ -1,49 +0,0 @@ -#include <stdio.h> -#include <string.h> -#include <sys/time.h> -#include <math.h> -#include <anydsl_runtime.h> - -typedef double real; -extern void run(real *, real, real); - -void print_usage(char *name) { - printf("Usage: %s dt steps\n", name); -} -int main(int argc, char** argv) { - if(argc != 3) { - print_usage(argv[0]); - return EXIT_FAILURE; - } - - double l[3]; - // planets - //l[0] = 1e308; - //l[1] = 1e308; - //l[2] = 1e308; - //run(4, l, 0.015, 468.5); - - l[0] = 250; - l[1] = 250; - l[2] = 250; - - //dt = 0.00005; - real dt = atof(argv[1]); - - struct timeval t1, t2; - gettimeofday(&t1, NULL); - run(l, dt, atol(argv[2])*dt); - gettimeofday(&t2, NULL); - double seconds = (t2.tv_sec - t1.tv_sec); // sec - seconds += (t2.tv_usec - t1.tv_usec) * 1e-6; // us to sec - if(seconds > 60.0) { - unsigned long minutes = (unsigned long)(floor(seconds / 60.0)); - seconds -= minutes * 60.0; - printf("Elapsed Time: %lu min %f s\n", minutes, seconds); - } - else { - printf("Elapsed Time: %f s\n", seconds); - } - - return EXIT_SUCCESS; -} diff --git a/apps/impala/mapping/mapping_acc.impala b/apps/impala/mapping/mapping_acc.impala deleted file mode 100644 index b7c5925cf858f9a4be27fe7cf7c2c756ef38a1a0..0000000000000000000000000000000000000000 --- a/apps/impala/mapping/mapping_acc.impala +++ /dev/null @@ -1 +0,0 @@ -fn alloc_array(size: i32) -> Buffer { acc.alloc(acc.dev(), size) } diff --git a/apps/impala/mapping/mapping_cpu.impala b/apps/impala/mapping/mapping_cpu.impala deleted file mode 100644 index 14727b7870b7112de0a78a0662c9dfcc405af89e..0000000000000000000000000000000000000000 --- a/apps/impala/mapping/mapping_cpu.impala +++ /dev/null @@ -1,2 +0,0 @@ -fn alloc_array(size: size_t) -> Buffer { alloc_cpu(size as i32) } - diff --git a/apps/impala/potential/gravitation.impala b/apps/impala/potential/gravitation.impala deleted file mode 100644 index 2b954f122d211dd16114074fca93a9873eabebeb..0000000000000000000000000000000000000000 --- a/apps/impala/potential/gravitation.impala +++ /dev/null @@ -1,14 +0,0 @@ -struct Constants { - r_cut: real -} - -fn force(p1: Particle, p2: Particle, constants: Constants) -> () -{ - let sqr = |x : real| {x*x}; - let dist = sub_vectors(p2.getCoordinates(), p1.getCoordinates()); - let r = dist.reduce(sqr, |x,y|{x+y}, 0.0); - let f = p1.getMass() * p2.getMass() / (math.sqrt(r)*r); - let tmp = scale_vector(f, dist); - p1.setForces(add_vectors(p1.getForces(), tmp)); - p2.setForces(sub_vectors(p2.getForces(), tmp)); -} diff --git a/apps/impala/potential/lennard_jones.impala b/apps/impala/potential/lennard_jones.impala deleted file mode 100644 index 6a2600fd171c4dbf629fc0d15c702f2e6a1d3704..0000000000000000000000000000000000000000 --- a/apps/impala/potential/lennard_jones.impala +++ /dev/null @@ -1,22 +0,0 @@ -struct Constants { - r_cut: real, - sigma: real, - epsilon: real -} - -fn force(p1: Particle, p2: Particle, constants: Constants) -> () -{ - let sqr = |x : real| {x*x}; - let dist = sub_vectors(p2.getCoordinates(), p1.getCoordinates()); - let r = dist.reduce(sqr, |x,y|{x+y}, 0.0); - if(r <= sqr(constants.r_cut)) { - let sigma = constants.sigma; - let epsilon = constants.epsilon; - let mut s = sqr(sigma)/r; - s = sqr(s)*s; - let f = 24.0 * epsilon * s / r * (1.0 - 2.0 * s); - let tmp = scale_vector(f, dist); - p1.setForces(add_vectors(p1.getForces(), tmp)); - p2.setForces(sub_vectors(p2.getForces(), tmp)); - } -} diff --git a/apps/impala/run/cpu.impala b/apps/impala/run/cpu.impala deleted file mode 100644 index d88f31c76a2bb1ad32d54c3b9251fceb1ac15d7b..0000000000000000000000000000000000000000 --- a/apps/impala/run/cpu.impala +++ /dev/null @@ -1,10 +0,0 @@ - - -extern -fn run(l: &[real], dt : real, t_end : real) -> () { - let mut constants : Constants; - init_constants(&mut constants); - let v = get_vector([l(0), l(1), l(2)]); - let P = init_particle_system(v, constants); - time_integration(0.0, t_end, dt, P); -} diff --git a/apps/impala/time_integration/cpu.impala b/apps/impala/time_integration/cpu.impala deleted file mode 100644 index a79dcff5f2037306999b0c14d0f60c0a217a0094..0000000000000000000000000000000000000000 --- a/apps/impala/time_integration/cpu.impala +++ /dev/null @@ -1,27 +0,0 @@ -fn time_integration(t_start: real, t_end: real, dt: real, P: ParticleSystem) -> () -{ - let mut t : real = t_start; - let mut count = 0 as size_t; - let mut i = 0 as size_t; - - let mut str : [u8 * 32]; - compute_force(P, force); - //print_particle_system(P); - - while(t < t_end) { - t += dt; - - /*if(count % (10 as size_t) == (0 as size_t)) { - generate_filename(i, &mut str, 32 as size_t); - fprint_particle_system(str, i, P); - ++i; - }*/ - - update(P, dt, integrate_x); - move_particles(P); - compute_force(P, force); - update(P, dt, integrate_v); - //print_statistics(P, t); - ++count; - } -} diff --git a/apps/impala/utilities/array/cpu.impala b/apps/impala/utilities/array/cpu.impala deleted file mode 100644 index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..0000000000000000000000000000000000000000 diff --git a/apps/impala/utilities/linked_cell/cpu.impala b/apps/impala/utilities/linked_cell/cpu.impala deleted file mode 100644 index 72cedea8c9fc435e5a1bb0b60d498298c930db22..0000000000000000000000000000000000000000 --- a/apps/impala/utilities/linked_cell/cpu.impala +++ /dev/null @@ -1,43 +0,0 @@ - - -fn iterate_over_particle_cells(start: [size_t * 3], end: [size_t * 3], P: ParticleSystem, f: fn([size_t * 3], &mut &ParticleList) -> ()) -> () { - for i in loop(start(0), end(0)) { - for j in loop(start(1), end(1)) { - for k in loop(start(2), end(2)){ - let ic = [i,j,k]; - f(ic, P.head(index(ic, P.nc()))); - } - } - } -} - - -fn iterate_over_particle_system(start: [size_t * 3], end: [size_t * 3], P: ParticleSystem, f: fn([size_t * 3], &ParticleList) -> ()) -> () { - for ic, head in iterate_over_particle_cells(start, end, P) { - for pl in iterate_over_list(**head) { - f(ic, pl); - } - } - /* - for i in loop(start(0), end(0)) { - for j in loop(start(1), end(1)) { - for k in loop(start(2), end(2)) { - let ic = [i,j,k]; - - for pl in iterate_over_list(*P.head(index(ic, P.nc()))) { - f(ic, pl); - } - } - } - }*/ -} - -fn iterate_over_list(ptr: &ParticleList, body: fn(&ParticleList) -> ()) -> () { - if((ptr) != (0 as & ParticleList)) { - body(ptr); - iterate_over_list((*ptr).next, body, return) - } -} - - - diff --git a/configure b/configure new file mode 100755 index 0000000000000000000000000000000000000000..2d6b66ed816bd5523e891e4486d73ba092a0f3a1 --- /dev/null +++ b/configure @@ -0,0 +1,2 @@ +#!/bin/sh +cmake . -DAnyDSL-runtime_DIR=/simdata/ja42rica/anydsl/runtime/