Skip to content

Commit e341e04

Browse files
committed
minor
1 parent a9e83d7 commit e341e04

File tree

7 files changed

+51
-22
lines changed

7 files changed

+51
-22
lines changed

CMakeLists.txt

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@ find_package(HDF5 REQUIRED COMPONENTS CXX)
99
find_package(OpenMP REQUIRED)
1010
# Boost
1111
find_package(Boost COMPONENTS program_options log log_setup REQUIRED)
12-
# Find TBB
13-
find_package(TBB REQUIRED)
1412
# FindCUDA module
1513
find_package(CUDA)
1614

@@ -43,11 +41,19 @@ include_directories(${Boost_INCLUDE_DIRS} ${HDF5_INCLUDE_DIRS} ./include ./src .
4341
# Add the executable
4442
add_executable(spinwalk ./src/spinwalk.cu ./src/kernels.cu ./src/file_utils.cpp ./src/shapes/shape_base.cpp ./src/shapes/cylinder.cpp ./src/shapes/sphere.cpp)
4543
# Link CUDA and OpenMP libraries
46-
target_link_libraries(spinwalk ${CUDA_LIBRARIES} ${OpenMP_CXX_LIBRARIES} ${Boost_LIBRARIES} ${HDF5_CXX_LIBRARIES} TBB::tbb)
47-
4844
if (UNIX)
49-
install(TARGETS spinwalk DESTINATION bin)
50-
endif()
45+
# Find TBB
46+
find_package(TBB REQUIRED)
47+
target_link_libraries(spinwalk ${CUDA_LIBRARIES} ${OpenMP_CXX_LIBRARIES} ${Boost_LIBRARIES} ${HDF5_CXX_LIBRARIES} TBB::tbb)
48+
install(TARGETS spinwalk DESTINATION bin)
49+
elseif (WIN32)
50+
IF(MSVC)
51+
ADD_DEFINITIONS("/EHsc")
52+
ENDIF(MSVC)
53+
target_link_libraries(spinwalk ${CUDA_LIBRARIES} ${OpenMP_CXX_LIBRARIES} ${Boost_LIBRARIES} ${HDF5_CXX_LIBRARIES})
54+
endif()
55+
56+
5157

5258
# cmake ..
5359
# cmake --build . --config Release

src/file_utils.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ bool file_utils::read_config(std::string config_filename, simulation_parameters
3535
return false;
3636
}
3737

38-
std::string cf_name = std::filesystem::path(config_filename).filename();
38+
std::string cf_name = std::filesystem::path(config_filename).filename().string();
3939
BOOST_LOG_TRIVIAL(info) << "Reading config: " << config_filename;
4040
boost::property_tree::ptree pt;
4141
boost::property_tree::ini_parser::read_ini(config_filename, pt);

src/shapes/cylinder.cpp

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@
1414
#include "cylinder.h"
1515
#include "basic_functions.cuh"
1616

17+
#ifndef M_PI
18+
#define M_PI 3.14159265358979323846
19+
#endif
1720

1821
cylinder::cylinder()
1922
{
@@ -42,7 +45,7 @@ void cylinder::set_cylinder_parameters(float radius, float orientation)
4245

4346
void cylinder::generate_shapes()
4447
{
45-
std::cout << "Generating coordinates...for BVF = " << m_BVF << "% ...\n";
48+
shape::generate_shapes();
4649
bool is_random_radius = m_radius < 0;
4750
float max_radius = m_radius>0 ? m_radius:-m_radius;
4851
m_cylinder_points.clear();
@@ -154,9 +157,9 @@ void cylinder::generate_mask_fieldmap()
154157
}
155158

156159
#pragma omp parallel for
157-
for(size_t pz=z_min; pz<z_max; pz++)
158-
for(size_t py=y_min; py<y_max; py++)
159-
for(size_t px=x_min; px<x_max; px++)
160+
for(int32_t pz=z_min; pz<z_max; pz++)
161+
for(int32_t py=y_min; py<y_max; py++)
162+
for(int32_t px=x_min; px<x_max; px++)
160163
{
161164
size_t p = px*res2 + py*res1 + pz;
162165
float *grid = &m_grid[3*p];
@@ -185,9 +188,10 @@ void cylinder::generate_mask_fieldmap()
185188
bar.progress(c, m_cylinder_radii.size());
186189
}
187190
bar.finish();
188-
m_BVF = std::accumulate(m_mask.begin(), m_mask.end(), 0) * 100.0 / res3;
191+
189192
auto end = std::chrono::high_resolution_clock::now();
190-
std::cout << "Cylinders generated successfully! BVF: " << m_BVF << "% Elapsed Time: " << std::chrono::duration_cast<std::chrono::seconds>(end - start).count() << " s\n";
193+
std::cout << "Cylinders generated successfully! " << "% Elapsed Time: " << std::chrono::duration_cast<std::chrono::seconds>(end - start).count() << " s\n";
194+
shape::generate_mask_fieldmap();
191195
}
192196

193197
void cylinder::print_info()

src/shapes/shape_base.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,17 @@ void shape::set_filename(std::string filename)
5555
this->m_filename = filename;
5656
}
5757

58+
void shape::generate_shapes()
59+
{
60+
std::cout << "Generating coordinates...for target BVF = " << m_BVF << "% ...\n";
61+
}
62+
63+
void shape::generate_mask_fieldmap()
64+
{
65+
m_BVF = std::accumulate(m_mask.begin(), m_mask.end(), 0) * 100.0 / m_mask.size();
66+
std::cout << "Actual BVF = " << m_BVF << "% ...\n";
67+
}
68+
5869
bool shape::save()
5970
{
6071
std::cout << "Saving the results..." << std::endl;
@@ -84,6 +95,11 @@ bool shape::save()
8495
std::vector<size_t> dims_fov(1, 3);
8596
HighFive::DataSet dataset_fov = file.createDataSet<float>("fov", HighFive::DataSpace(dims_fov));
8697
dataset_fov.write_raw(fov);
98+
// blood volume fraction
99+
std::vector<size_t> dims_1(1, 1);
100+
HighFive::DataSet dataset_BVF = file.createDataSet<float>("bvf", HighFive::DataSpace(dims_1));
101+
dataset_BVF.write_raw(&m_BVF);
102+
87103
return true;
88104
}
89105

src/shapes/shape_base.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ class shape
2525
virtual bool run(){return true;};
2626
virtual bool save();
2727
virtual bool create_grid();
28-
virtual void generate_shapes() = 0;
29-
virtual void generate_mask_fieldmap() = 0;
28+
virtual void generate_shapes();
29+
virtual void generate_mask_fieldmap();
3030
virtual void print_info();
3131

3232
protected:

src/shapes/sphere.cpp

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@
1414
#include "sphere.h"
1515
#include "basic_functions.cuh"
1616

17-
17+
#ifndef M_PI
18+
#define M_PI 3.14159265358979323846
19+
#endif
1820
// -------------------------------------------------------------------------- //
1921
sphere::sphere()
2022
{
@@ -38,7 +40,7 @@ void sphere::set_sphere_parameters(float radius)
3840

3941
void sphere::generate_shapes()
4042
{
41-
std::cout << "Generating coordinates for BVF = " << m_BVF << "% ...\n";
43+
shape::generate_shapes();
4244
bool is_random_radius = m_radius < 0;
4345
float max_radius = m_radius>0 ? m_radius:-m_radius;
4446
m_sphere_points.clear();
@@ -142,9 +144,9 @@ void sphere::generate_mask_fieldmap()
142144
}
143145

144146
#pragma omp parallel for
145-
for(size_t pz=z_min; pz<z_max; pz++)
146-
for(size_t py=y_min; py<y_max; py++)
147-
for(size_t px=x_min; px<x_max; px++)
147+
for(int32_t pz=z_min; pz<z_max; pz++)
148+
for(int32_t py=y_min; py<y_max; py++)
149+
for(int32_t px=x_min; px<x_max; px++)
148150
{
149151
size_t p = px*res2 + py*res1 + pz;
150152
float *grid = (float *)m_grid.data() + 3*p;
@@ -164,9 +166,9 @@ void sphere::generate_mask_fieldmap()
164166
bar.progress(c, m_sphere_radii.size());
165167
}
166168
bar.finish();
167-
m_BVF = std::accumulate(m_mask.begin(), m_mask.end(), 0) * 100.0 / res3;
168169
auto end = std::chrono::high_resolution_clock::now();
169-
std::cout << "Spheres generated successfully! Actual BVF: " << m_BVF << "% Elapsed Time: " << std::chrono::duration_cast<std::chrono::seconds>(end - start).count() << " s\n";
170+
std::cout << "Spheres generated successfully! " << "% Elapsed Time: " << std::chrono::duration_cast<std::chrono::seconds>(end - start).count() << " s\n";
171+
shape::generate_mask_fieldmap();
170172
}
171173

172174
void sphere::print_info()

src/spinwalk.cu

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
#include <thrust/host_vector.h>
3434
#include <thrust/device_vector.h>
3535
#include <thrust/copy.h>
36+
#include <thrust/iterator/constant_iterator.h>
3637
#else
3738
#define checkCudaErrors(x) {}
3839
#endif

0 commit comments

Comments
 (0)