Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Namespaces #551

Merged
merged 43 commits into from
Jul 8, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
ae7c0e9
Add the flamegpu::, flamegpu::util:: and flamegpu::visualiser namespaces
ptheywood May 17, 2021
be6bf4e
Rename BUILD_SWIG_PYTHON_VIRTUALENV to BUILD_SWIG_PYTHON_VENV
ptheywood Jun 17, 2021
f442383
Place the python output files into a config specific folder
ptheywood Jun 17, 2021
40ebccd
Remove the <os>-x64 from lib/bin paths.
ptheywood Jun 17, 2021
8e7ae5e
Suppress CMake version deprecation warning for rapidjson
ptheywood Jun 18, 2021
5dbfae4
Renaame flamegpu/flame_api.h -> flamegpu/flamegpu.h
ptheywood Jun 18, 2021
b93b80c
Examples should only include flamegpu/flamegpu.h
ptheywood Jun 18, 2021
3ee13ee
Delete flamegpu/runtime/flamegpu_api.h it was unneccesary
ptheywood Jun 18, 2021
fd87c9b
Rename flamegpu::flamegpu_internal to flamegpu::detail
ptheywood Jun 18, 2021
f2c5680
flamegpu::curve_internal -> flamegpu::curve::detail
ptheywood Jun 18, 2021
ddbab65
RunPlanVec -> RunPlanVector
ptheywood Jun 18, 2021
e678950
Rename variables cuda_model to cudaSimulation
ptheywood Jun 18, 2021
25615fb
exception/FGPUStaticAssert -> flamegpu::util::StaticAssert
ptheywood Jun 18, 2021
74278ad
File / Class renaming and splitting for the io directory
ptheywood Jun 23, 2021
d12d0b0
Create the flamegpu::io namespace
ptheywood Jun 24, 2021
636bead
Prevent jitify, tinyxml2 and detail namespaces from appearing in doxygen
ptheywood Jun 24, 2021
79b35d2
Provide AgentVariableHash struct instead of specialisaing template in…
ptheywood Jun 24, 2021
037d3b2
Utility for pairs of <string, unsigned> and maps with these pairs as …
ptheywood Jun 24, 2021
cce0031
flamegpu::exception namespace
ptheywood Jun 24, 2021
39791ac
Disable some printf's from DependencyGraph
ptheywood Jun 24, 2021
b3dd2f6
Remove deprecated curve error checking methods / symbols
ptheywood Jun 25, 2021
2573be3
AgentFunction.h->.cuh and AgentFunctionData.h->.cuh.
ptheywood Jun 28, 2021
fa89ceb
Add missing __threadsync in the AgentFunction{Condition}Wrapper
ptheywood Jun 28, 2021
5ac6145
Remove unused Exceptions. Closes #578
ptheywood Jun 28, 2021
8782977
Remove use of DependencyGraph default constructor in boids_bruteforce…
ptheywood Jun 28, 2021
66caa47
CUDAErrorChecking.h -> .cuh
ptheywood Jun 28, 2021
f67dc51
FGPU -> FLAMEGPU
ptheywood Jun 29, 2021
02b3436
Add an id_t python test from test_cuda_simulation
ptheywood Jun 29, 2021
9e969a9
Only include ModelVis.h in CUDASimualtion if VISUSALTION is enabled
ptheywood Jun 29, 2021
c28d87b
flamegpu::FLAME_GPU_AGENT_STATUS -> flamegpu::AGENT_STATUS
ptheywood Jun 29, 2021
1fc45b0
Move MemoryVector into detail
ptheywood Jun 29, 2021
4c78196
Split GenericMemoryVector to its own header file
ptheywood Jun 29, 2021
e3d8a0f
Move non-public util API classes int util::detail
ptheywood Jun 30, 2021
1d79595
Move CUDAErrorChecking into flamegpu::detail
ptheywood Jun 30, 2021
70427ed
Remove unneccesary #includes
ptheywood Jun 30, 2021
6e2f243
Place curve into flamegpu::detail::curve
ptheywood Jun 30, 2021
8e46a76
.h->.cuh where headers include device symbols (__global__, __device__…
ptheywood Jul 1, 2021
7d44bf3
RTC: only inlucde the required message types for a given kernel.
ptheywood Jul 1, 2021
3ea4901
FLAMEGPU_CONDITION_RESULT -> flamegpu::CONDITION_RESULT
ptheywood Jul 2, 2021
5608031
Remove deprecated curve enums from curve_rtc dynamic headers
ptheywood Jul 2, 2021
87b463c
Split MsgSpecialisationHandler to its own file
ptheywood Jul 7, 2021
2a33ff4
Update visualisation includes to use the new directory paths
ptheywood Jul 7, 2021
d808bc5
Update CI to CUDA 11.4
ptheywood Jul 7, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 2 additions & 0 deletions .github/scripts/install_cuda_windows.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ $CUDA_KNOWN_URLS = @{
"11.2.1" = "https://developer.download.nvidia.com/compute/cuda/11.2.1/network_installers/cuda_11.2.1_win10_network.exe";
"11.2.2" = "https://developer.download.nvidia.com/compute/cuda/11.2.2/network_installers/cuda_11.2.2_win10_network.exe";
"11.3.0" = "https://developer.download.nvidia.com/compute/cuda/11.3.0/network_installers/cuda_11.3.0_win10_network.exe"
"11.3.1" = "https://developer.download.nvidia.com/compute/cuda/11.3.1/network_installers/cuda_11.3.1_win10_network.exe"
"11.4.0" = "https://developer.download.nvidia.com/compute/cuda/11.4.0/network_installers/cuda_11.4.0_win10_network.exe"
}

# @todo - change this to be based on _MSC_VER intead, or invert it to be CUDA keyed instead?
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/Lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
matrix:
include:
- os: ubuntu-latest
cuda: "11.3"
cuda: "11.4"
env:
build_dir: "build"
build_tests: "ON"
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/Ubuntu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ jobs:
# explicit include-based build matrix, of known valid options
matrix:
include:
# 20.04 supports CUDA 11.0+ (gcc >= 5 && gcc <= 10). SM < 52 deprecated since 11.0
# 20.04 supports CUDA 11.0+ (gcc >= 5 && gcc <= 10.2). SM < 52 deprecated since 11.0
- os: ubuntu-20.04
cuda: "11.3"
cuda: "11.4"
cuda_arch: "52"
gcc: 9
# 18.04 supports CUDA 10.0+ (gcc <=8), 11.0+ (gcc<=9), 11.1+ (gcc<=10)
Expand Down Expand Up @@ -64,7 +64,7 @@ jobs:
run: sudo apt-get install python3-venv

- name: Configure cmake
run: cmake . -B ${{ env.build_dir }} -DCMAKE_BUILD_TYPE=${{ env.config }} -DBUILD_TESTS=${{ env.build_tests }} -DWARNINGS_AS_ERRORS=${{ env.Werror }} -DCUDA_ARCH="${{ matrix.cuda_arch }}" -Werror=dev -DBUILD_SWIG_PYTHON=ON -DBUILD_SWIG_PYTHON_VIRTUALENV=ON -DUSE_NVTX=ON
run: cmake . -B ${{ env.build_dir }} -DCMAKE_BUILD_TYPE=${{ env.config }} -DBUILD_TESTS=${{ env.build_tests }} -DWARNINGS_AS_ERRORS=${{ env.Werror }} -DCUDA_ARCH="${{ matrix.cuda_arch }}" -Werror=dev -DBUILD_SWIG_PYTHON=ON -DUSE_NVTX=ON

- name: Build flamegpu2
run: cmake --build . --target flamegpu2 --verbose -j `nproc`
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/Windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
include:
# Windows2019 & VS 2019 supports 10.1+
- os: windows-2019
cuda: "11.3.0"
cuda: "11.4.0"
cuda_arch: 52
visual_studio: "Visual Studio 16 2019"
# - os: windows-2019
Expand Down Expand Up @@ -57,7 +57,7 @@ jobs:
# Windows GHA fix: specify Python3_ROOT_DIR and _EXECUTABLE to make sure python.exe is found, not python3.exe which does not work with venv
- name: Configure CMake
id: configure
run: cmake . -B ${{ env.build_dir }} -G "${{ matrix.visual_studio }}" -A x64 -DBUILD_TESTS=${{ env.build_tests }} -DWARNINGS_AS_ERRORS=${{ env.werror }} -DCUDA_ARCH="${{ matrix.cuda_arch }}" -Werror=dev -DBUILD_SWIG_PYTHON=ON -DBUILD_SWIG_PYTHON_VIRTUALENV=ON -DPython3_ROOT_DIR=$(dirname $(which python)) -DPython3_EXECUTABLE=$(which python) -DUSE_NVTX=ON
run: cmake . -B ${{ env.build_dir }} -G "${{ matrix.visual_studio }}" -A x64 -DBUILD_TESTS=${{ env.build_tests }} -DWARNINGS_AS_ERRORS=${{ env.werror }} -DCUDA_ARCH="${{ matrix.cuda_arch }}" -Werror=dev -DBUILD_SWIG_PYTHON=ON -DPython3_ROOT_DIR=$(dirname $(which python)) -DPython3_EXECUTABLE=$(which python) -DUSE_NVTX=ON
shell: bash

- name: Build flamegpu2
Expand Down
5 changes: 2 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,8 @@ if(NOT NO_EXAMPLES)
endif()

option(BUILD_SWIG_PYTHON "Enable python bindings via SWIG" OFF)
cmake_dependent_option(BUILD_SWIG_PYTHON_VIRTUALENV "Enable building of SWIG Python Virtual Env for Python Testing" OFF
"BUILD_SWIG_PYTHON" OFF)

# By default, build into a venv, otherwise it is set to ON anyway.
cmake_dependent_option(BUILD_SWIG_PYTHON_VENV "Enable the use of a venv for swig/python installation" ON "BUILD_SWIG_PYTHON" ON)


# Option to enable/disable tests.
Expand Down
2 changes: 1 addition & 1 deletion CPPLINT.cfg
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
set noparent
linelength=240
linelength=320
filter=-legal/copyright,-readability/todo,-runtime/references,-build/c++11
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ cmake ..

##### Visualisation

By default FGPU2 will not build visualisations, however this can be enabled with the cmake option `-DVISUALISATION=ON`. This also introduces the `VISUALISATION` preprocessor macro to all projects, so that optional visualisation code can be enabled.
By default FLAME GPU 2 will not build visualisations, however this can be enabled with the cmake option `-DVISUALISATION=ON`. This also introduces the `VISUALISATION` preprocessor macro to all projects, so that optional visualisation code can be enabled.

On Windows this will then automatically download the visualisation repository and all dependencies, as such the initial CMake configuration after enabling visualisation may take longer than expected.
On Linux you may need to install additional packages, refer to the CMake configure output for clarification of which packages are missing from your system.
Expand Down Expand Up @@ -211,7 +211,7 @@ I.e. `-DUSE_NVTX=ON` will enable NVTX markers and allow custom markers to be inc
See `include/util/nvtx.h` and the associated documentation for how to apply custom markers.

### Running FLAME GPU 2
Examples for FLAME GPU 2 build to `<cmake_build_path>/bin/<operating_system>-x64/<Debug|Release|Profile>/`, and can be executed from that directory via command line.
Examples for FLAME GPU 2 build to `<cmake_build_path>/bin/<Debug|Release|Profile>/`, and can be executed from that directory via command line.

If wishing to run examples within Visual Studio it is necessary to right click the desired example in the Solution Explorer and select `Debug > Start New Instance`. Alternatively, if `Set as StartUp Project` is selected, the main debugging menus can be used to initiate execution. To configure command line argument for execution within Visual Studio, right click the desired example in the Solution Explorer and select `Properties`, in this dialog select `Debugging` in the left hand menu to display the entry field for `command arguments`. Note, it may be necessary to change the configuration as the properties dialog may be targeting a different configuration to the current build configuration.

Expand Down
5 changes: 2 additions & 3 deletions cmake/Tinyxml2.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,12 @@ if(NOT tinyxml2_POPULATED)

# Set location of static library files
# Define output location of static library
STRING(TOLOWER "${CMAKE_SYSTEM_NAME}" CMAKE_SYSTEM_NAME_LOWER)
if(CMAKE_SOURCE_DIR STREQUAL PROJECT_SOURCE_DIR)
# If top level project
SET(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/lib/${CMAKE_SYSTEM_NAME_LOWER}-x64/${CMAKE_BUILD_TYPE}/)
SET(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/lib/${CMAKE_BUILD_TYPE}/)
else()
# If called via add_subdirectory()
SET(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/../lib/${CMAKE_SYSTEM_NAME_LOWER}-x64/${CMAKE_BUILD_TYPE}/)
SET(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/../lib/${CMAKE_BUILD_TYPE}/)
endif()

# Depends on the cpp and header files in case of changes
Expand Down
13 changes: 11 additions & 2 deletions cmake/common.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@ include(${CMAKE_CURRENT_LIST_DIR}/Tinyxml2.cmake)
include(${CMAKE_CURRENT_LIST_DIR}/rapidjson.cmake)

# Common rules for other cmake files
# Make available lowercase 'linux'/'windows' vars (used for build dirs)
STRING(TOLOWER "${CMAKE_SYSTEM_NAME}" CMAKE_SYSTEM_NAME_LOWER)
# Don't create installation scripts (and hide CMAKE_INSTALL_PREFIX from cmake-gui)
set(CMAKE_SKIP_INSTALL_RULES TRUE)
set(CMAKE_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}" CACHE INTERNAL "" FORCE)
Expand Down Expand Up @@ -590,6 +588,17 @@ function(add_flamegpu_library NAME SRC FLAMEGPU_ROOT)
target_compile_definitions(${NAME} PUBLIC "THRUST_IGNORE_DEPRECATED_CPP_DIALECT")
endif()
endif()

# Compiler flags which we do not want to be set to all targets
# GNU specific flags.
# @todo - make this not just applied to the library, but also executables.
# @todo - currently disabled as tinyxml2 include is not marked as system (because it's inherrited via properties on the imported target). Might require https://gitlab.kitware.com/cmake/cmake/-/issues/18040 to be implemented to actually achieve this.
# if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
# target_compile_options(${NAME} PRIVATE -Wsuggest-override)
# set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} -Xcompiler -Wsuggest-override")
# set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wsuggest-override")
# set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wsuggest-override")
# endif()

# Thrust uses isystem if available
target_link_libraries(${NAME} Thrust::Thrust)
Expand Down
7 changes: 5 additions & 2 deletions cmake/doxygen.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,14 @@ function(create_doxygen_target FLAMEGPU_ROOT DOXY_OUT_DIR XML_PATH)
set(DOXYGEN_WARN_AS_ERROR YES)
endif()
endif()
# These are required for expanding FGPUException definition macros to be documented
# Ignore some namespaces where forward declarationss lead to empty namespaces in the docs.
# @todo - optionally don't block detail, for developer docs
set(DOXYGEN_EXCLUDE_SYMBOLS "jitify" "tinyxml2" "detail")
# These are required for expanding FLAMEGPUException definition macros to be documented
set(DOXYGEN_ENABLE_PREPROCESSING YES)
set(DOXYGEN_MACRO_EXPANSION YES)
set(DOXYGEN_EXPAND_ONLY_PREDEF YES)
set(DOXYGEN_PREDEFINED "DERIVED_FGPUException(name,default_msg)=class name: public FGPUException { public: explicit name(const char *format = default_msg)\; }" "VISUALISATION= ")
set(DOXYGEN_PREDEFINED "DERIVED_FLAMEGPUException(name,default_msg)=class name: public flamegpu::FLAMEGPUException { public: explicit name(const char *format = default_msg)\; }" "VISUALISATION= ")
set(DOXY_INPUT_FILES "${FLAMEGPU_ROOT}/include;${FLAMEGPU_ROOT}/src;${FLAMEGPU_ROOT}/README.md")
# Create doxygen target
if("${XML_PATH}" STREQUAL "")
Expand Down
2 changes: 1 addition & 1 deletion cmake/rapidjson.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ if(NOT rapidjson_POPULATED)
FetchContent_Populate(rapidjson)
# RapidJSON has custom RapidJSONConfig.cmake, generated by cmake configure/generate
execute_process(
COMMAND ${CMAKE_COMMAND} . -DRAPIDJSON_BUILD_DOC=OFF -DRAPIDJSON_BUILD_EXAMPLES=OFF -DRAPIDJSON_BUILD_TESTS=OFF -DRAPIDJSON_BUILD_THIRDPARTY_GTEST=OFF
COMMAND ${CMAKE_COMMAND} . -DRAPIDJSON_BUILD_DOC=OFF -DRAPIDJSON_BUILD_EXAMPLES=OFF -DRAPIDJSON_BUILD_TESTS=OFF -DRAPIDJSON_BUILD_THIRDPARTY_GTEST=OFF -Wno-deprecated
WORKING_DIRECTORY "${rapidjson_SOURCE_DIR}"
OUTPUT_QUIET
)
Expand Down
6 changes: 4 additions & 2 deletions cmake/version.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,12 @@

#include <string>

namespace flamegpu_internal {
namespace flamegpu {
namespace detail {
inline std::string getCommitHash() {
return "${SHORT_HASH}";
}
} // namespace flamegpu_internal
} // namespace detail
} // namespace flamegpu

#endif // INCLUDE_FLAMEGPU_VERSION_H_
4 changes: 2 additions & 2 deletions examples/boids_bruteforce/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ include(${FLAMEGPU_ROOT}/cmake/common.cmake)
# Define output location of binary files
if(CMAKE_SOURCE_DIR STREQUAL PROJECT_SOURCE_DIR)
# If top level project
SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/bin/${CMAKE_SYSTEM_NAME_LOWER}-x64/${CMAKE_BUILD_TYPE}/)
SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/bin/${CMAKE_BUILD_TYPE}/)
else()
# If called via add_subdirectory()
SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/../../bin/${CMAKE_SYSTEM_NAME_LOWER}-x64/${CMAKE_BUILD_TYPE}/)
SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/../../bin/${CMAKE_BUILD_TYPE}/)
endif()

# Prepare list of source files
Expand Down
55 changes: 27 additions & 28 deletions examples/boids_bruteforce/src/main.cu
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#include <iostream>
#include <fstream>

#include "flamegpu/flame_api.h"
#include "flamegpu/flamegpu.h"

/**
* FLAME GPU 2 implementation of the Boids model, using BruteForce messaging.
Expand Down Expand Up @@ -113,23 +113,23 @@ FLAMEGPU_HOST_DEVICE_FUNCTION void clampPosition(float &x, float &y, float &z, c


/**
* outputdata agent function for Boid agents, which outputs publicly visible properties to a message list
* outputdata agent funFLAMEGPU_AGENT_FUNCTIONction for Boid agents, which outputs publicly visible properties to a message list
*/
FLAMEGPU_AGENT_FUNCTION(outputdata, MsgNone, MsgBruteForce) {
FLAMEGPU_AGENT_FUNCTION(outputdata, flamegpu::MsgNone, flamegpu::MsgBruteForce) {
// Output each agents publicly visible properties.
FLAMEGPU->message_out.setVariable<id_t>("id", FLAMEGPU->getID());
FLAMEGPU->message_out.setVariable<flamegpu::id_t>("id", FLAMEGPU->getID());
FLAMEGPU->message_out.setVariable<float>("x", FLAMEGPU->getVariable<float>("x"));
FLAMEGPU->message_out.setVariable<float>("y", FLAMEGPU->getVariable<float>("y"));
FLAMEGPU->message_out.setVariable<float>("z", FLAMEGPU->getVariable<float>("z"));
FLAMEGPU->message_out.setVariable<float>("fx", FLAMEGPU->getVariable<float>("fx"));
FLAMEGPU->message_out.setVariable<float>("fy", FLAMEGPU->getVariable<float>("fy"));
FLAMEGPU->message_out.setVariable<float>("fz", FLAMEGPU->getVariable<float>("fz"));
return ALIVE;
return flamegpu::ALIVE;
}
/**
* inputdata agent function for Boid agents, which reads data from neighbouring Boid agents, to perform the boid flocking model.
*/
FLAMEGPU_AGENT_FUNCTION(inputdata, MsgBruteForce, MsgNone) {
FLAMEGPU_AGENT_FUNCTION(inputdata, flamegpu::MsgBruteForce, flamegpu::MsgNone) {
// Agent properties in local register
const int id = FLAMEGPU->getID();
// Agent position
Expand Down Expand Up @@ -163,7 +163,7 @@ FLAMEGPU_AGENT_FUNCTION(inputdata, MsgBruteForce, MsgNone) {
// Iterate location messages, accumulating relevant data and counts.
for (const auto &message : FLAMEGPU->message_in) {
// Ignore self messages.
if (message.getVariable<id_t>("id") != id) {
if (message.getVariable<flamegpu::id_t>("id") != id) {
// Get the message location and velocity.
const float message_x = message.getVariable<float>("x");
const float message_y = message.getVariable<float>("y");
Expand Down Expand Up @@ -282,14 +282,14 @@ FLAMEGPU_AGENT_FUNCTION(inputdata, MsgBruteForce, MsgNone) {
FLAMEGPU->setVariable<float>("fy", agent_fy);
FLAMEGPU->setVariable<float>("fz", agent_fz);

return ALIVE;
return flamegpu::ALIVE;
}

int main(int argc, const char ** argv) {
ModelDescription model("Boids_BruteForce");
flamegpu::ModelDescription model("Boids_BruteForce");

{ // Location message
MsgBruteForce::Description &message = model.newMessage("location");
flamegpu::MsgBruteForce::Description &message = model.newMessage("location");
// A message to hold the location of an agent.
message.newVariable<int>("id");
message.newVariable<float>("x");
Expand All @@ -300,7 +300,7 @@ int main(int argc, const char ** argv) {
message.newVariable<float>("fz");
}
{ // Boid agent
AgentDescription &agent = model.newAgent("Boid");
flamegpu::AgentDescription &agent = model.newAgent("Boid");
agent.newVariable<float>("x");
agent.newVariable<float>("y");
agent.newVariable<float>("z");
Expand All @@ -316,7 +316,7 @@ int main(int argc, const char ** argv) {
* GLOBALS
*/
{
EnvironmentDescription &env = model.Environment();
flamegpu::EnvironmentDescription &env = model.Environment();

// Population size to generate, if no agents are loaded from disk
env.newProperty("POPULATION_TO_GENERATE", 32768u);
Expand Down Expand Up @@ -347,27 +347,26 @@ int main(int argc, const char ** argv) {
* Control flow
*/
{ // Layer #1
LayerDescription &layer = model.newLayer();
flamegpu::LayerDescription &layer = model.newLayer();
layer.addAgentFunction(outputdata);
}
{ // Layer #2
LayerDescription &layer = model.newLayer();
flamegpu::LayerDescription &layer = model.newLayer();
layer.addAgentFunction(inputdata);
}


/**
* Create Model Runner
*/
CUDASimulation cuda_model(model);
flamegpu::CUDASimulation cudaSimulation(model);

/**
* Create visualisation
*/
#ifdef VISUALISATION
ModelVis &visualisation = cuda_model.getVisualisation();
flamegpu::visualiser::ModelVis &visualisation = cudaSimulation.getVisualisation();
{
EnvironmentDescription &env = model.Environment();
flamegpu::EnvironmentDescription &env = model.Environment();
float envWidth = env.getProperty<float>("MAX_POSITION") - env.getProperty<float>("MIN_POSITION");
const float INIT_CAM = env.getProperty<float>("MAX_POSITION") * 1.25f;
visualisation.setInitialCameraLocation(INIT_CAM, INIT_CAM, INIT_CAM);
Expand All @@ -378,27 +377,27 @@ int main(int argc, const char ** argv) {
circ_agt.setForwardXVariable("fx");
circ_agt.setForwardYVariable("fy");
circ_agt.setForwardZVariable("fz");
circ_agt.setModel(Stock::Models::ICOSPHERE);
circ_agt.setModel(flamegpu::visualiser::Stock::Models::ICOSPHERE);
circ_agt.setModelScale(env.getProperty<float>("SEPARATION_RADIUS"));
}
visualisation.activate();
#endif

// Initialisation
cuda_model.initialise(argc, argv);
cudaSimulation.initialise(argc, argv);

// If no xml model file was is provided, generate a population.
if (cuda_model.getSimulationConfig().input_file.empty()) {
EnvironmentDescription &env = model.Environment();
if (cudaSimulation.getSimulationConfig().input_file.empty()) {
flamegpu::EnvironmentDescription &env = model.Environment();
// Uniformly distribute agents within space, with uniformly distributed initial velocity.
std::mt19937 rngEngine(cuda_model.getSimulationConfig().random_seed);
std::mt19937 rngEngine(cudaSimulation.getSimulationConfig().random_seed);
std::uniform_real_distribution<float> position_distribution(env.getProperty<float>("MIN_POSITION"), env.getProperty<float>("MAX_POSITION"));
std::uniform_real_distribution<float> velocity_distribution(-1, 1);
std::uniform_real_distribution<float> velocity_magnitude_distribution(env.getProperty<float>("MIN_INITIAL_SPEED"), env.getProperty<float>("MAX_INITIAL_SPEED"));
const unsigned int populationSize = env.getProperty<unsigned int>("POPULATION_TO_GENERATE");
AgentVector population(model.Agent("Boid"), populationSize);
flamegpu::AgentVector population(model.Agent("Boid"), populationSize);
for (unsigned int i = 0; i < populationSize; i++) {
AgentVector::Agent instance = population[i];
flamegpu::AgentVector::Agent instance = population[i];

// Agent position in space
instance.setVariable<float>("x", position_distribution(rngEngine));
Expand All @@ -420,19 +419,19 @@ int main(int argc, const char ** argv) {
instance.setVariable<float>("fy", fy);
instance.setVariable<float>("fz", fz);
}
cuda_model.setPopulationData(population);
cudaSimulation.setPopulationData(population);
}

/**
* Execution
*/
cuda_model.simulate();
cudaSimulation.simulate();


/**
* Export Pop
*/
// cuda_model.exportData("end.xml");
// cudaSimulation.exportData("end.xml");

#ifdef VISUALISATION
visualisation.join();
Expand Down
4 changes: 2 additions & 2 deletions examples/boids_bruteforce_dependency_graph/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ include(${FLAMEGPU_ROOT}/cmake/common.cmake)
# Define output location of binary files
if(CMAKE_SOURCE_DIR STREQUAL PROJECT_SOURCE_DIR)
# If top level project
SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/bin/${CMAKE_SYSTEM_NAME_LOWER}-x64/${CMAKE_BUILD_TYPE}/)
SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/bin/${CMAKE_BUILD_TYPE}/)
else()
# If called via add_subdirectory()
SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/../../bin/${CMAKE_SYSTEM_NAME_LOWER}-x64/${CMAKE_BUILD_TYPE}/)
SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/../../bin/${CMAKE_BUILD_TYPE}/)
endif()

# Prepare list of source files
Expand Down
Loading