Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
82 commits
Select commit Hold shift + click to select a range
be0887a
eclipse project files, ignore build directories by git
BerndDoser Apr 4, 2016
204e5a5
write and read tipsy input files for testing
BerndDoser Apr 5, 2016
c93f9c0
cmake configs for eclipse
Apr 6, 2016
3c4ae02
add eclipse test runs
BerndDoser Apr 7, 2016
5318abc
#617: galaxies vector, release key, add particles to gpu memory
BerndDoser Apr 12, 2016
426135c
#617: allocate doubled memory
Apr 13, 2016
3bfd44b
generalize eclipse configs by using CMAKE_HOME and ESO_DATA
BerndDoser Apr 14, 2016
5c6bdac
add iterate_setup to release_galaxy
BerndDoser Apr 14, 2016
d7414a9
#617: reallocateParticleMemory
BerndDoser Apr 15, 2016
e77b06b
#617: octree::addGalaxy
BerndDoser Apr 15, 2016
4e463b5
#619: Split GTCDemo file into two galaxies
BerndDoser Apr 18, 2016
98f39e4
test release GTC12 demo galaxy 1
BerndDoser Apr 18, 2016
d569f54
build all tipsy tools with cmake
BerndDoser Apr 18, 2016
fc0c6b1
move path for test galaxies
BerndDoser May 2, 2016
c0ab90d
GalaxyStore
BerndDoser May 3, 2016
16da673
getTotalVelocity, addVelocity
May 5, 2016
e7dcb3e
read galaxies into galaxyStore
BerndDoser May 6, 2016
b5071e7
test sockest for python/C IPC
BerndDoser May 6, 2016
3cbdf1e
read line in python
BerndDoser May 6, 2016
b5de639
test non-blocking socket interconnection between python and c++
BerndDoser May 9, 2016
6ecb5c7
test bidirectional stream socket
BerndDoser May 10, 2016
364d41d
test non-blocking bidirectinal socket interconnent
BerndDoser May 10, 2016
5136fe3
typo
BerndDoser May 10, 2016
a524d01
integrate galaxyStore into releaseGalaxy
BerndDoser May 10, 2016
ce87e55
release galaxy from GalaxyStore
May 11, 2016
b436698
WOGSocketManager
May 12, 2016
1f6b55b
WOGSocketManager and glut test
BerndDoser May 12, 2016
ae3bb09
set correct position and velocity for release galaxies
BerndDoser May 13, 2016
3175c3b
move tipsy tests
BerndDoser May 13, 2016
57a89ba
read and use socket data, correct release of galaxies, switch on C++11
BerndDoser May 17, 2016
db027fc
add velocity to released galaxies
BerndDoser May 17, 2016
0e6e9bd
bugfix galaxy_id
May 18, 2016
a680b91
Use json format for data exchange
BerndDoser May 19, 2016
02f3303
remove galaxies of a user
BerndDoser May 20, 2016
c5cbce8
remove all particles of a user
BerndDoser May 23, 2016
fef6db7
remove particles of a user
BerndDoser May 24, 2016
8f15fe2
Remove particles of a user
May 27, 2016
83cfffc
endless loop, remove particles
BerndDoser May 27, 2016
08721bf
Some changes in interface
BerndDoser May 31, 2016
49f41e5
some changes in interface
Jun 2, 2016
eca0220
Adjust the galaxy release velocity to pixels/s on the simulation plane.
BerndDoser Jun 2, 2016
078c994
- Add a bonsai command flag "--del_radius_factor" to scale the radius of
BerndDoser Jun 2, 2016
219220f
- bugfix simulation_plane_width
BerndDoser Jun 3, 2016
30c13d8
Send simulation time in interface request "report"
BerndDoser Jun 3, 2016
cda3fa5
Remove particles continuously during simulation
BerndDoser Jun 6, 2016
02cb3b3
First refactoring and improve error checks of data send via socket
Jun 8, 2016
a437331
Only allow bonsai command flags which are needed by WarOfGalaxies
BerndDoser Jun 9, 2016
d6ce57b
do not print statistics at WOG mode by default
BerndDoser Jun 9, 2016
9291a31
Only allow bonsai command flags which are needed by WarOfGalaxies
BerndDoser Jun 9, 2016
d65f9e6
use thrust for removing particles
BerndDoser Jun 14, 2016
ebbfa5e
add missing include
Jun 15, 2016
c7b9856
Merge remote-tracking branch 'upstream/master'
Jun 15, 2016
8155bdd
enable thrust, Listening socket with SO_REUSEADDR
Jun 15, 2016
5edbc00
use thrust to continuously remove particles outside sphere
BerndDoser Jun 17, 2016
662deca
#680: set fullscreen without using game mode
BerndDoser Aug 23, 2016
e1ff3ff
#677: non-blocking client socket
BerndDoser Aug 25, 2016
9bd2ef2
catch thrust::remove_if, remove inclusion of thrust, thrust is
BerndDoser Aug 29, 2016
1909f61
switch on thrust debugging
BerndDoser Aug 29, 2016
c2b1567
debug thrust::remove_if
BerndDoser Aug 30, 2016
dd6f7c1
use dev_mem for user_particles
Aug 31, 2016
8c4c844
Feature #673: Manipulate device memory directly for removing particles
Sep 7, 2016
8f4be51
reformat Bonsai network response
Sep 29, 2016
d5e64e7
Merge pull request #1 from vga101/response-format
BerndDoser Sep 29, 2016
2fd44a6
Use number_of_users instead of hard coded number
BerndDoser Sep 29, 2016
47ede32
add eclipse launch
BerndDoser Dec 12, 2017
ee29809
Merge remote-tracking branch 'treecode/master'
BerndDoser Dec 14, 2017
12c4273
adapt changes to current merge with master branch
BerndDoser Dec 15, 2017
5ad6d27
correct number_of_users allocation and change type to ullong
BerndDoser Dec 18, 2017
aa51c9e
fix #1211: Camera distance not correctly set
BerndDoser Dec 18, 2017
e584f78
replace jsoncons by submodule version 0.100.2
BerndDoser Dec 18, 2017
4419b7a
fix ullong thrust and cleanup tools/war-of-galaxies
BerndDoser Dec 19, 2017
ac29395
cleanup to run Bonsai without war-of-galaxies part
BerndDoser Dec 19, 2017
8aa4ba5
go back to original fullscreen option
BerndDoser Dec 19, 2017
eae87ae
more cleanup to run Bonsai without war-of-galaxies part
BerndDoser Dec 19, 2017
aaaac02
docu
BerndDoser Dec 19, 2017
20efc1a
Fix: Use center-of-mass velocity for steady galaxy
Jan 25, 2018
bc34ebc
Renaming related to total_velocity fix
Jan 25, 2018
1fdd357
Re-allow some command options
Jan 25, 2018
61563c2
Update README.md of WOG
Jan 25, 2018
d249042
Fix compiler warning
Jan 25, 2018
99dc9a3
Merge pull request #2 from vga101/wog-fix
BerndDoser Jan 26, 2018
4984399
Add Jenkinsfile for continuous integration (#3)
BerndDoser Jan 26, 2018
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
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "runtime/extern/jsoncons"]
path = runtime/extern/jsoncons
url = https://github.com/danielaparker/jsoncons.git
22 changes: 22 additions & 0 deletions runtime/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,11 @@ option(CUDA_KEEP_INTERMEDIATE_FILES
OFF
)

option(WAR_OF_GALAXIES
"On to enable WarOfGalaxies"
OFF
)

FIND_PACKAGE(CUDA REQUIRED)

add_definitions(-std=c++11)
Expand Down Expand Up @@ -278,6 +283,23 @@ if (USE_OPENGL)

endif (USE_OPENGL)

if (WAR_OF_GALAXIES)
add_definitions(-DWAR_OF_GALAXIES)
add_definitions("-std=c++11")
include_directories(${CMAKE_SOURCE_DIR}/extern/jsoncons/include)
set (CCFILES ${CCFILES}
src/Galaxy.cpp
src/read_tipsy_file_parallel.cpp
src/WOGManager.cpp
)
set (CUFILES ${CUFILES}
CUDAkernels/war_of_galaxies.cu
)
if (USE_THRUST)
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DTHRUST_DEBUG")
endif()
endif (WAR_OF_GALAXIES)

#The SSE support for the local tree walks
if(WIN32)
add_definitions( "/arch:SSE4")
Expand Down
84 changes: 84 additions & 0 deletions runtime/CUDAkernels/war_of_galaxies.cu
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
/*
* war_of_galaxies.cu
*
* Created on: Jun 14, 2016
* Author: Bernd Doser <bernd.doser@h-its.org>
*/

#ifdef USE_THRUST

#include "bonsai.h"
#include "thrust_war_of_galaxies.h"
#include <thrust/execution_policy.h>
#include <thrust/device_ptr.h>
#include <thrust/device_vector.h>
#include <thrust/remove.h>

/// Functor return true if position is out of sphere
struct OutOfSphereChecker
{
OutOfSphereChecker(real deletion_radius_square)
: deletion_radius_square(deletion_radius_square)
{}

__device__
bool operator()(thrust::tuple<real4, real4, ullong> const& t) const
{
real4 position = thrust::get<0>(t);
return position.x * position.x + position.y * position.y + position.z * position.z > deletion_radius_square
and thrust::get<2>(t) % 10 != 9;
}

real deletion_radius_square;
};

/// Functor return true if modules is equal
struct EqualToModulus10
{
EqualToModulus10(int user_id)
: user_id(user_id)
{}

__device__
bool operator()(int i) const
{
return i % 10 == user_id;
}

int user_id;
};

// Remove particles out of sphere
extern "C" void remove_particles(tree_structure &tree,
real deletion_radius_square, my_dev::dev_mem<uint> &user_particles, int number_of_users)
{
thrust::device_ptr<real4> thrust_pos = thrust::device_pointer_cast(tree.bodies_pos.raw_p());
thrust::device_ptr<real4> thrust_vel = thrust::device_pointer_cast(tree.bodies_vel.raw_p());
thrust::device_ptr<ullong> thrust_ids = thrust::device_pointer_cast(tree.bodies_ids.raw_p());
thrust::device_ptr<uint> thrust_user_particles = thrust::device_pointer_cast(user_particles.raw_p());

try {
// auto is not working, compiler assume int
thrust::zip_iterator< thrust::tuple<thrust::device_ptr<real4>, thrust::device_ptr<real4>, thrust::device_ptr<ullong> > > new_end =
thrust::remove_if(
thrust::device,
thrust::make_zip_iterator(thrust::make_tuple(thrust_pos, thrust_vel, thrust_ids)),
thrust::make_zip_iterator(thrust::make_tuple(thrust_pos + tree.n, thrust_vel + tree.n, thrust_ids + tree.n)),
OutOfSphereChecker(deletion_radius_square)
);

// Set new number of particles
tree.n = thrust::get<0>(new_end.get_iterator_tuple()) - thrust_pos;

// Update user particles
for (int i(0); i != number_of_users; ++i)
thrust_user_particles[i] = thrust::count_if(thrust_ids, thrust_ids + tree.n, EqualToModulus10(i));
}
catch(thrust::system_error &e)
{
std::cerr << "Error accessing vector element: " << e.what() << std::endl;
exit(-1);
}
}

#endif
1 change: 1 addition & 0 deletions runtime/extern/jsoncons
Submodule jsoncons added at 3d8df1
43 changes: 43 additions & 0 deletions runtime/include/Galaxy.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/*
* Galaxies.h
*
* Created on: Apr 12, 2016
* Author: Bernd Doser <bernd.doser@h-its.org>
*/

#pragma once

#include <my_cuda_rt.h>
#include <vector>

typedef unsigned long long ullong;

/// One defined galaxy
struct Galaxy
{
/// Center of mass
real4 getCenterOfMass() const;

/// Center-of-mass Velocity
real4 getCenterOfMassVelocity() const;

/// Move center of mass to origin (0,0,0)
void centering();

/// Remove center-of-mass velocity
void steady();

/// Move center of the galaxy
void translate(real4 w);

/// Accelerate the galaxy
void accelerate(real4 w);

std::vector<real4> pos;
std::vector<real4> vel;
std::vector<ullong> ids;

std::vector<real4> pos_dust;
std::vector<real4> vel_dust;
std::vector<ullong> ids_dust;
};
111 changes: 111 additions & 0 deletions runtime/include/WOGManager.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
/*
* WOGManager.h
*
* Created on: May 11, 2016
* Author: Bernd Doser <bernd.doser@h-its.org>
*/

#pragma once

#include "Galaxy.h"
#include "octree.h"
#include "jsoncons/json.hpp"
#include <array>
#include <arpa/inet.h>
#include <fcntl.h>
#include <netdb.h>
#include <netinet/in.h>
#include <stdio.h>
#include <string.h>
#include <sys/socket.h>
#include <sys/types.h>
#include <unistd.h>
#include <cstdlib>
#include <iostream>
#include <string>
#include <stdexcept>

struct sockaddr_in;

/**
* War of Galaxies (WOG)
* - Store galaxy type which can be released
* - Control interconnection via UNIX socket
* - Add and remove particles to running simulation
*/
class WOGManager
{
public:

/// Constructor opening sockets and reading input galaxies
WOGManager(octree *tree, std::string const& path, int port, int window_width, int window_height, real fovy,
real farZ, real camera_distance, real deletion_radius_factor);

/// Constructor closing the sockets
~WOGManager();

/// Execute a client request
void execute();

/// Must be called by glutReshapeFunc
void reshape(int width, int height);

/// Return camera distance
real get_camera_distance() const { return camera_distance; }

private:

/// Read all galaxy types
void read_galaxies(std::string const& path);

/// Remove particles continuously
void remove_particles();

/// Execute a client request
jsoncons::json execute_json(std::string const& buffer);

octree *tree;

int server_socket;

int client_socket;

/// Number of users
static constexpr auto number_of_users = 4;

/// Buffer size for socket data transmission
static constexpr auto buffer_size = 1024;

/// Maximal number of particles of a user
static constexpr auto max_number_of_particles_of_user = 100000;

/// Number of particles of user
my_dev::dev_mem<uint> user_particles;

/// Dimension of the window
int window_width;
int window_height;

/// OpenGL viewing angle
real fovy;

/// OpenGL distance of clipping plane
real farZ;

/// Distance of the OpenGL camera
real camera_distance;

/// Dimension of the window
real simulation_plane_width;
real simulation_plane_height;

/// Scaling factor for deletion sphere.
real deletion_radius_factor;

/// Squared radius of deletion sphere. Particles leaving this sphere will be removed.
real deletion_radius_square;

/// Galaxy types which can be released
std::vector<Galaxy> galaxies;

};
11 changes: 9 additions & 2 deletions runtime/include/octree.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,7 @@
#include <unistd.h>
#endif



#include "Galaxy.h"

typedef float real;
typedef float2 real2;
Expand Down Expand Up @@ -681,6 +680,14 @@ class octree {

//End functions for parallel code

// WarOfGalaxies: add galaxy to simulation
void releaseGalaxy(Galaxy const& galaxy);

// WarOfGalaxies: remove particles of a user
void removeGalaxy(int user_id);

// WarOfGalaxies: remove particles out of sphere continuously
void removeParticles(real deletion_radius_square, my_dev::dev_mem<uint> &user_particles, int number_of_users);

//Library interface functions
void setEps(float eps);
Expand Down
21 changes: 21 additions & 0 deletions runtime/include/read_tipsy_file_parallel.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/*
* read_tipsy_file_parallel.h
*
* Created on: May 6, 2016
* Author: Bernd Doser <bernd.doser@h-its.org>
*/

#pragma once

#include <my_cuda_rt.h>
#include <octree.h>
#include <vector>

void read_tipsy_file_parallel(std::vector<real4> &bodyPositions, std::vector<real4> &bodyVelocities,
std::vector<ullong> &bodiesIDs, float eps2, string fileName,
int rank, int procs, int &NTotal2, int &NFirst,
int &NSecond, int &NThird, octree *tree,
std::vector<real4> &dustPositions, std::vector<real4> &dustVelocities,
std::vector<ullong> &dustIDs, int reduce_bodies_factor,
int reduce_dust_factor,
const bool restart);
6 changes: 4 additions & 2 deletions runtime/include/renderloop.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@
#define _RENDERLOOP_H_

#include "octree.h"

extern float TstartGlow;
extern float dTstartGlow;

void initGL(int argc, char** argv, const char *fullScreenMode, bool &stereo);
void initAppRenderer(int argc, char** argv, octree *tree,
octree::IterationData &idata,
bool showFPS, bool stereo);
octree::IterationData &idata, bool showFPS, bool stereo,
std::string const& wogPath, int wogPort,
real wogCameraDistance, real wogDeletionRadiusFactor);

#endif // _RENDERLOOP_H_
14 changes: 14 additions & 0 deletions runtime/include/thrust_war_of_galaxies.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/*
* thrust_war_of_galaxies.h
*
* Created on: Jun 15, 2016
* Author: Bernd Doser <bernd.doser@h-its.org>
*/

#pragma once

#include <octree.h>

/// Remove particles behind visualization sphere
extern "C" void remove_particles(tree_structure &tree,
real deletion_radius_square, my_dev::dev_mem<uint> &user_particles, int number_of_users);
Loading