Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
6 changes: 3 additions & 3 deletions SimulationCode/Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
CUDA_INSTALL_PATH ?= /usr/local/cuda-9.2/bin
CUDA_INSTALL_PATH ?= /usr/local/cuda/bin
CXX := /usr/bin/g++
LDFLAGS=-lglfw -lGL
NVCC := $(CUDA_INSTALL_PATH)/nvcc
Expand All @@ -14,9 +14,9 @@ CUOBJS := $(subst src,build,$(CUOBJS))
TARGET := $(OUTDIR)/main

# Options
NVCCOPTIONS =-O3 -m64 -arch=sm_35 -std=c++14 -g
NVCCOPTIONS =-O3 -m64 -arch=sm_35 -std=c++11 -g
#NVCCOPTIONS =-O3 -m64 -std=c++14 -g
CXXOPTIONS =-O3 -m64 -std=c++14 -g -Wall -I /usr/local/cuda/include/
CXXOPTIONS =-O3 -m64 -std=c++11 -g -Wall -I /usr/local/cuda/include/

# Common flags
NVCCFLAGS += $(NVCCOPTIONS)
Expand Down
15 changes: 15 additions & 0 deletions SimulationCode/PerformanceTest.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
make clean
make -j5
out="output"
out+=$1
echo ${out}

echo $1 > input
echo "100" >> input
./out/main < input > ${out}
for i in {0..50}
do
echo $1 > input
echo $((1000 + $i*2000)) >> input
./out/main < input >> ${out}
done
Empty file added SimulationCode/chart2
Empty file.
4 changes: 2 additions & 2 deletions SimulationCode/input
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
4
100000
2
95000
48 changes: 48 additions & 0 deletions SimulationCode/output2
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
(100,0.000147255)
(1000,0.00100808)
(3000,0.00286826)
(5000,0.00483034)
(7000,0.00709195)
(9000,0.00980842)
(11000,0.0131749)
(13000,0.0167023)
(15000,0.0205186)
(17000,0.0281992)
(19000,0.0315434)
(21000,0.0350184)
(23000,0.0387652)
(25000,0.0429775)
(27000,0.0480237)
(29000,0.0527792)
(31000,0.0580048)
(33000,0.0851563)
(35000,0.0945012)
(37000,0.103412)
(39000,0.110675)
(41000,0.120121)
(43000,0.136063)
(45000,0.142862)
(47000,0.151272)
(49000,0.159093)
(51000,0.168716)
(53000,0.178091)
(55000,0.185694)
(57000,0.195938)
(59000,0.206165)
(61000,0.21761)
(63000,0.228704)
(65000,0.239777)
(67000,0.300484)
(69000,0.313557)
(71000,0.328274)
(73000,0.345043)
(75000,0.360973)
(77000,0.376232)
(79000,0.391146)
(81000,0.406964)
(83000,0.423311)
(85000,0.439855)
(87000,0.466543)
(89000,0.48233)
(91000,0.494591)
(93000,0.511687)
52 changes: 52 additions & 0 deletions SimulationCode/output4
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
(100,0.00826626)
(1000,0.0145179)
(3000,0.0219876)
(5000,0.0501732)
(7000,0.0480744)
(9000,0.0454484)
(11000,0.0442917)
(13000,0.0421267)
(15000,0.0429789)
(17000,0.0511684)
(19000,0.0436969)
(21000,0.0445312)
(23000,0.0452354)
(25000,0.0453264)
(27000,0.049968)
(29000,0.047501)
(31000,0.0521729)
(33000,0.0483408)
(35000,0.0498652)
(37000,0.0513726)
(39000,0.0540352)
(41000,0.0534255)
(43000,0.0584782)
(45000,0.056337)
(47000,0.053342)
(49000,0.0504997)
(51000,0.0531557)
(53000,0.0583203)
(55000,0.0546283)
(57000,0.0532342)
(59000,0.0703022)
(61000,0.054763)
(63000,0.0551174)
(65000,0.0766021)
(67000,0.0989813)
(69000,0.0857285)
(71000,0.0693708)
(73000,0.0610821)
(75000,0.0669189)
(77000,0.10345)
(79000,0.104832)
(81000,0.0791419)
(83000,0.0702073)
(85000,0.0853074)
(87000,0.12837)
(89000,0.118374)
(91000,0.087911)
(93000,0.0833733)
(95000,0.0727809)
(97000,0.0687188)
(99000,0.0826717)
(101000,0.0929585)
47 changes: 47 additions & 0 deletions SimulationCode/src/.vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
{
"files.associations": {
"chrono": "cpp",
"cctype": "cpp",
"cmath": "cpp",
"cstddef": "cpp",
"cstdio": "cpp",
"cstdlib": "cpp",
"cstring": "cpp",
"ctime": "cpp",
"cwchar": "cpp",
"array": "cpp",
"atomic": "cpp",
"strstream": "cpp",
"*.tcc": "cpp",
"clocale": "cpp",
"cstdint": "cpp",
"cwctype": "cpp",
"deque": "cpp",
"unordered_map": "cpp",
"vector": "cpp",
"exception": "cpp",
"fstream": "cpp",
"functional": "cpp",
"initializer_list": "cpp",
"iosfwd": "cpp",
"iostream": "cpp",
"istream": "cpp",
"limits": "cpp",
"memory": "cpp",
"new": "cpp",
"ostream": "cpp",
"numeric": "cpp",
"ratio": "cpp",
"sstream": "cpp",
"stdexcept": "cpp",
"streambuf": "cpp",
"system_error": "cpp",
"thread": "cpp",
"cinttypes": "cpp",
"type_traits": "cpp",
"tuple": "cpp",
"typeindex": "cpp",
"typeinfo": "cpp",
"utility": "cpp"
}
}
2 changes: 1 addition & 1 deletion SimulationCode/src/BarnesHutStep.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class BarnesHutStep : public Step {
std::vector<float> forces;
std::vector<float> velocities;
float sizeFrame = 8.0;
const float theta = 0.5;
const float theta = 2.0;
const float EPS = 0.01;
};

Expand Down
4 changes: 3 additions & 1 deletion SimulationCode/src/ComputationsBarnesHutCuda.cu
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
#include "ComputationsBarnesHutCuda.h"
#include <thrust/sort.h>
#include <thrust/extrema.h>
#include <thrust/unique.h>
#include <bitset>
#include <string>

const float G = 6.674 * (1e-11);
const float EPS = 0.01f;
const float theta = 2;
const float theta = 2.0;
const int THREADS_PER_BLOCK = 1024;
const int K = 15;

Expand Down
21 changes: 8 additions & 13 deletions SimulationCode/src/Main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,54 +3,49 @@ using namespace std;

int main() {
int programVersion, numberOfBodies;
printf("Wybierz tryb wykonywania programu\n");
//printf("Wybierz tryb wykonywania programu\n");
while (1) {
printf("1. Naiwny algorytm CPU\n2. Naiwny algorytm GPU\n3. Algorytm "
"Barnes-Hut CPU\n4. Algorytm Barnes-Hut GPU\n");
//printf("1. Naiwny algorytm CPU\n2. Naiwny algorytm GPU\n3. Algorytm "
// "Barnes-Hut CPU\n4. Algorytm Barnes-Hut GPU\n");
int res = scanf("%d", &programVersion);
if (programVersion > 4 || programVersion <= 0) {
printf("Nie ma takiej opcji, sprobuj ponownie\n");
//printf("Nie ma takiej opcji, sprobuj ponownie\n");
continue;
}
break;
}
printf("Podaj liczbę jednostek do poddania symulacji\n");
//printf("Podaj liczbę jednostek do poddania symulacji\n");
int res = scanf("%d", &numberOfBodies);
if(res == EOF) return 1;
RandomGenerators *randomGenerator = new RandomGenerators();
std::vector<float> masses(numberOfBodies);
randomGenerator->initializeWeights(masses, numberOfBodies);
Render *rend = nullptr;
Step *step = nullptr;
Simulation *sim;

switch (programVersion) {
case 1: {
rend = new Render(masses, numberOfBodies, 1.0);
step = new StepNaive(masses, numberOfBodies);
break;
}
case 2: {
rend = new Render(masses, numberOfBodies, 1.0);
step = new StepNaiveCuda(masses, numberOfBodies);
break;
}
case 3: {
rend = new Render(masses, numberOfBodies, 8.0);
step = new BarnesHutStep(masses, numberOfBodies);
break;
}
case 4: {
rend = new Render(masses, numberOfBodies, -1);
step = new BarnesHutStepCuda(masses, numberOfBodies);
break;
}
default:
break;
}
sim = new Simulation(rend, step, numberOfBodies);
sim->MakeSimulation();

sim = new Simulation(step, numberOfBodies);
for(int kk=9900; kk<=70000; kk+=500)
sim->MakeSimulation(kk);
delete randomGenerator;
return 0;
}
2 changes: 1 addition & 1 deletion SimulationCode/src/RandomGenerators.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ void RandomGenerators::initializeWeights(std::vector<float> &weights, unsigned n
weights.resize(numberOfBodies);
int typeMass = 3;
unsigned divi;
printf("TYP %d\n", typeMass);
//printf("TYP %d\n", typeMass);
switch (typeMass) {
case 0:
for (unsigned i = 0; i < numberOfBodies; i++)
Expand Down
Loading