Skip to content

Commit a52df58

Browse files
authored
Merge pull request #104 from MultithreadCorner/develop-hydra3
Merging latest developments on cb-prng tests, sampling and unweighting.
2 parents 0401f5e + a4b6393 commit a52df58

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+3845
-874
lines changed

CMakeLists.txt

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,15 @@ if(OPENMP_CXX_FOUND OR OPENMP_FOUND)
129129
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
130130
endif(OPENMP_CXX_FOUND OR OPENMP_FOUND)
131131

132+
#-----------------------
133+
#get TestU01
134+
set(TESTU01_ROOT "/usr")
135+
set(TESTU01_LINK_DIR "/usr/lib64")
136+
find_package(TestU01)
137+
if(TESTU01_FOUND)
138+
include_directories(${TESTU01_INCLUDE_DIRS})
139+
endif(TESTU01_FOUND)
140+
132141
#generate API documentation with Doxygen
133142
#find_package(Doxygen)
134143
option(BUILD_DOCUMENTATION "Create and install the HTML based API documentation (requires Doxygen)" NO)
@@ -215,13 +224,6 @@ enable_testing()
215224
add_custom_target(tests)
216225
add_subdirectory(testing)
217226

218-
#add_dependencies(tests
219-
#Hydra_Test_Host_OMP_Device_CUDA
220-
#Hydra_Test_Host_CPP_Device_CUDA
221-
#Hydra_Test_Host_OMP_Device_OMP
222-
#Hydra_Test_Host_CPP_Device_OMP
223-
#)
224-
225227
#+++++++++++++++++++++++++++
226228
# DOXYGEN +
227229
#+++++++++++++++++++++++++++

cmake/FindTestU01.cmake

Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
# TestU01: http://www.iro.umontreal.ca/~simardr/testu01/tu01.html
2+
#
3+
# TESTU01_FOUND - System has TestU01
4+
# TESTU01_INCLUDE_DIRS - The TestU01 include directories
5+
# TESTU01_LIBRARIES - The libraries needed to use TestU01
6+
#
7+
# Set TESTU01_ROOT before calling find_package to a path to add an additional
8+
# search path, e.g.,
9+
#
10+
# Usage:
11+
#
12+
# set(TESTU01_ROOT "/path/to/custom/testu01") # prefer over system
13+
# find_package(TestU01)
14+
# if(TESTU01_FOUND)
15+
# target_link_libraries (TARGET ${TESTU01_LIBRARIES})
16+
# endif()
17+
18+
# If already in cache, be silent
19+
if(TESTU01_INCLUDE_DIRS AND TESTU01_LIBRARIES)
20+
set (TESTU01_FIND_QUIETLY TRUE)
21+
endif()
22+
23+
find_path(TESTU01_INCLUDE_SRES NAMES sres.h
24+
HINTS ${TESTU01_ROOT}/include
25+
$ENV{TESTU01_ROOT}/include)
26+
find_path(TESTU01_INCLUDE_SSTRING NAMES sstring.h
27+
HINTS ${TESTU01_ROOT}/include
28+
$ENV{TESTU01_ROOT}/include)
29+
find_path(TESTU01_INCLUDE_SKNUTH NAMES sknuth.h
30+
HINTS ${TESTU01_ROOT}/include
31+
$ENV{TESTU01_ROOT}/include)
32+
find_path(TESTU01_INCLUDE_SWALK NAMES swalk.h
33+
HINTS ${TESTU01_ROOT}/include
34+
$ENV{TESTU01_ROOT}/include)
35+
find_path(TESTU01_INCLUDE_SMARSA NAMES smarsa.h
36+
HINTS ${TESTU01_ROOT}/include
37+
$ENV{TESTU01_ROOT}/include)
38+
find_path(TESTU01_INCLUDE_SCOMP NAMES scomp.h
39+
HINTS ${TESTU01_ROOT}/include
40+
$ENV{TESTU01_ROOT}/include)
41+
find_path(TESTU01_INCLUDE_SSPECTRAL NAMES sspectral.h
42+
HINTS ${TESTU01_ROOT}/include
43+
$ENV{TESTU01_ROOT}/include)
44+
find_path(TESTU01_INCLUDE_UNIF01 NAMES unif01.h
45+
HINTS ${TESTU01_ROOT}/include
46+
$ENV{TESTU01_ROOT}/include)
47+
find_path(TESTU01_INCLUDE_SNPAIR NAMES snpair.h
48+
HINTS ${TESTU01_ROOT}/include
49+
$ENV{TESTU01_ROOT}/include)
50+
find_path(TESTU01_INCLUDE_GDEF NAMES gdef.h
51+
HINTS ${TESTU01_ROOT}/include
52+
$ENV{TESTU01_ROOT}/include)
53+
find_path(TESTU01_INCLUDE_GOFW NAMES gofw.h
54+
HINTS ${TESTU01_ROOT}/include
55+
$ENV{TESTU01_ROOT}/include)
56+
find_path(TESTU01_INCLUDE_SVARIA NAMES svaria.h
57+
HINTS ${TESTU01_ROOT}/include
58+
$ENV{TESTU01_ROOT}/include)
59+
find_path(TESTU01_INCLUDE_SWRITE NAMES swrite.h
60+
HINTS ${TESTU01_ROOT}/include
61+
$ENV{TESTU01_ROOT}/include)
62+
63+
set(TESTU01_INCLUDE_DIRS ${TESTU01_INCLUDE_SRES}
64+
${TESTU01_INCLUDE_SSTRING}
65+
${TESTU01_INCLUDE_SKNUTH}
66+
${TESTU01_INCLUDE_SWALK}
67+
${TESTU01_INCLUDE_SMARSA}
68+
${TESTU01_INCLUDE_SCOMP}
69+
${TESTU01_INCLUDE_SSPECTRAL}
70+
${TESTU01_INCLUDE_UNIF01}
71+
${TESTU01_INCLUDE_SNPAIR}
72+
${TESTU01_INCLUDE_GDEF}
73+
${TESTU01_INCLUDE_GOFW}
74+
${TESTU01_INCLUDE_SVARIA}
75+
${TESTU01_INCLUDE_SWRITE})
76+
77+
list(REMOVE_DUPLICATES TESTU01_INCLUDE_DIRS)
78+
79+
if(NOT BUILD_SHARED_LIBS)
80+
find_library(TESTU01_LIBRARY NAMES libtestu01.so HINTS ${TESTU01_ROOT}/lib64
81+
$ENV{TESTU01_ROOT}/lib64)
82+
find_library(TESTU01_PROBDIST_LIBRARY NAMES libprobdist.so
83+
HINTS ${TESTU01_ROOT}/lib64
84+
$ENV{TESTU01_ROOT}/lib64)
85+
find_library(TESTU01_MYLIB_LIBRARY NAMES libmylib.so
86+
HINTS ${TESTU01_ROOT}/lib64
87+
$ENV{TESTU01_ROOT}/lib64)
88+
else()
89+
find_library(TESTU01_LIBRARY NAMES testu01 HINTS ${TESTU01_ROOT}/lib64
90+
$ENV{TESTU01_ROOT}/lib64)
91+
find_library(TESTU01_PROBDIST_LIBRARY NAMES probdist
92+
HINTS ${TESTU01_ROOT}/lib64
93+
$ENV{TESTU01_ROOT}/lib64)
94+
find_library(TESTU01_MYLIB_LIBRARY NAMES mylib
95+
HINTS ${TESTU01_ROOT}/lib64
96+
$ENV{TESTU01_ROOT}/lib64)
97+
endif()
98+
99+
set(TESTU01_LIBRARIES ${TESTU01_LIBRARY} ${TESTU01_PROBDIST_LIBRARY}
100+
${TESTU01_MYLIB_LIBRARY})
101+
102+
# Handle the QUIETLY and REQUIRED arguments and set TESTU01_FOUND to TRUE if
103+
# all listed variables are TRUE.
104+
INCLUDE(FindPackageHandleStandardArgs)
105+
FIND_PACKAGE_HANDLE_STANDARD_ARGS(TestU01 DEFAULT_MSG TESTU01_LIBRARIES TESTU01_INCLUDE_DIRS)
106+
107+
if(NOT TestU01_FOUND)
108+
set(TESTU01_INCLUDE_DIRS "")
109+
set(TESTU01_LIBRARIES "")
110+
endif()
111+
112+
MARK_AS_ADVANCED(TESTU01_INCLUDE_DIRS TESTU01_LIBRARIES)
113+

examples/random/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,4 @@ ADD_HYDRA_EXAMPLE(fill_basic_distributions BUILD_CUDA_TARGETS BUILD_TBB_TARGETS
88
ADD_HYDRA_EXAMPLE(sample_distribution BUILD_CUDA_TARGETS BUILD_TBB_TARGETS BUILD_OMP_TARGETS BUILD_CPP_TARGETS)
99
ADD_HYDRA_EXAMPLE(booststrapping BUILD_CUDA_TARGETS BUILD_TBB_TARGETS BUILD_OMP_TARGETS BUILD_CPP_TARGETS)
1010
ADD_HYDRA_EXAMPLE(sobol_quasirandom BUILD_CUDA_TARGETS BUILD_TBB_TARGETS BUILD_OMP_TARGETS BUILD_CPP_TARGETS)
11+
ADD_HYDRA_EXAMPLE(unweight_sample BUILD_CUDA_TARGETS BUILD_TBB_TARGETS BUILD_OMP_TARGETS BUILD_CPP_TARGETS)

examples/random/basic_distributions.inl

Lines changed: 2 additions & 169 deletions
Original file line numberDiff line numberDiff line change
@@ -33,165 +33,6 @@
3333
*
3434
*/
3535

36-
/*
37-
#include <iostream>
38-
#include <assert.h>
39-
#include <time.h>
40-
#include <chrono>
41-
42-
//command line
43-
#include <tclap/CmdLine.h>
44-
45-
//this lib
46-
#include <hydra/device/System.h>
47-
#include <hydra/host/System.h>
48-
#include <hydra/Function.h>
49-
#include <hydra/Lambda.h>
50-
#include <hydra/Random.h>
51-
#include <hydra/Algorithm.h>
52-
*/
53-
/*-------------------------------------
54-
* Include classes from ROOT to fill
55-
* and draw histograms and plots.
56-
*-------------------------------------
57-
*/
58-
/*
59-
#ifdef _ROOT_AVAILABLE_
60-
61-
#include <TROOT.h>
62-
#include <TH1D.h>
63-
#include <TApplication.h>
64-
#include <TCanvas.h>
65-
66-
#endif //_ROOT_AVAILABLE_
67-
68-
69-
70-
int main(int argv, char** argc)
71-
{
72-
size_t nentries = 0;
73-
74-
try {
75-
76-
TCLAP::CmdLine cmd("Command line arguments for ", '=');
77-
78-
TCLAP::ValueArg<size_t> EArg("n", "number-of-events","Number of events", true, 10e6, "size_t");
79-
cmd.add(EArg);
80-
81-
// Parse the argv array.
82-
cmd.parse(argv, argc);
83-
84-
// Get the value parsed by each arg.
85-
nentries = EArg.getValue();
86-
87-
}
88-
catch (TCLAP::ArgException &e) {
89-
std::cerr << "error: " << e.error() << " for arg " << e.argId()
90-
<< std::endl;
91-
}
92-
93-
94-
//generator
95-
hydra::Random<>
96-
Generator( std::chrono::system_clock::now().time_since_epoch().count() );
97-
98-
99-
//device
100-
//------------------------
101-
#ifdef _ROOT_AVAILABLE_
102-
103-
TH1D hist_uniform_d("uniform_d", "Uniform", 100, -6.0, 6.0);
104-
TH1D hist_gaussian_d("gaussian_d", "Gaussian", 100, -6.0, 6.0);
105-
TH1D hist_exp_d("exponential_d", "Exponential", 100, 0.0, 5.0);
106-
TH1D hist_bw_d("breit_wigner_d", "Breit-Wigner",100, 0.0, 5.0);
107-
108-
#endif //_ROOT_AVAILABLE_
109-
110-
{
111-
//1D device buffer
112-
hydra::device::vector<double> data_d(nentries);
113-
hydra::host::vector<double> data_h(nentries);
114-
115-
//-------------------------------------------------------
116-
//uniform
117-
Generator.Uniform(-5.0, 5.0, data_d.begin(), data_d.end());
118-
hydra::copy(data_d, data_h);
119-
120-
for(size_t i=0; i<10; i++)
121-
std::cout << "< Random::Uniform > [" << i << "] :" << data_d[i] << std::endl;
122-
123-
#ifdef _ROOT_AVAILABLE_
124-
for(auto value : data_h)
125-
hist_uniform_d.Fill( value);
126-
#endif //_ROOT_AVAILABLE_
127-
128-
//-------------------------------------------------------
129-
//gaussian
130-
Generator.Gauss(0.0, 1.0, data_d.begin(), data_d.end());
131-
hydra::copy(data_d, data_h);
132-
133-
for(size_t i=0; i<10; i++)
134-
std::cout << "< Random::Gauss > [" << i << "] :" << data_d[i] << std::endl;
135-
136-
#ifdef _ROOT_AVAILABLE_
137-
for(auto value : data_d)
138-
hist_gaussian_d.Fill( value);
139-
#endif //_ROOT_AVAILABLE_
140-
141-
//-------------------------------------------------------
142-
//exponential
143-
Generator.Exp(1.0, data_d);
144-
hydra::copy(data_d, data_h);
145-
146-
for(size_t i=0; i<10; i++)
147-
std::cout << "< Random::Exp > [" << i << "] :" << data_d[i] << std::endl;
148-
149-
#ifdef _ROOT_AVAILABLE_
150-
for(auto value : data_h)
151-
hist_exp_d.Fill( value);
152-
#endif //_ROOT_AVAILABLE_
153-
154-
//-------------------------------------------------------
155-
//breit-wigner
156-
Generator.BreitWigner(2.0, 0.2, data_d.begin(), data_d.end());
157-
hydra::copy(data_d, data_h);
158-
159-
for(size_t i=0; i<10; i++)
160-
std::cout << "< Random::BreitWigner > [" << i << "] :" << data_d[i] << std::endl;
161-
162-
#ifdef _ROOT_AVAILABLE_
163-
for(auto value : data_h)
164-
hist_bw_d.Fill( value);
165-
#endif //_ROOT_AVAILABLE_
166-
}
167-
168-
169-
170-
171-
#ifdef _ROOT_AVAILABLE_
172-
TApplication *myapp=new TApplication("myapp",0,0);
173-
174-
//draw histograms
175-
TCanvas canvas_d("canvas_d" ,"Distributions - Device", 1000, 1000);
176-
canvas_d.Divide(2,2);
177-
canvas_d.cd(1); hist_uniform_d.Draw("hist");
178-
canvas_d.cd(2); hist_gaussian_d.Draw("hist");
179-
canvas_d.cd(3); hist_exp_d.Draw("hist");
180-
canvas_d.cd(4); hist_bw_d.Draw("hist");
181-
182-
183-
184-
myapp->Run();
185-
186-
#endif //_ROOT_AVAILABLE_
187-
188-
return 0;
189-
190-
191-
192-
}
193-
194-
*/
19536
#include <iostream>
19637
#include <assert.h>
19738
#include <time.h>
@@ -262,17 +103,9 @@ auto data = hydra::device::vector< double>(10, .0);
262103
//Parameters
263104
auto mean = hydra::Parameter::Create("mean" ).Value(0.0);
264105
auto sigma = hydra::Parameter::Create("sigma").Value(0.25);
106+
auto gauss = hydra::Gaussian<xvar>(mean, sigma);
265107

266-
auto gauss = hydra::Gaussian<xvar>(mean, sigma);
267-
268-
for(auto x: data)
269-
std::cout << ">>>>>>>>>"<<hydra::detail::is_valid_type_pack<hydra_thrust::tuple<xvar> , decltype(x) >::value << std::endl;
270-
//x.dummy;
271-
//std::cout << gauss(x) << std::endl;
272-
273-
274-
275-
//LogNormal distribution
108+
//LogNormal distribution
276109
auto lognormal = hydra::LogNormal<xvar>(mean, sigma);
277110

278111

examples/random/fill_basic_distributions.inl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
#include <hydra/device/System.h>
4848
#include <hydra/Parameter.h>
4949
#include <hydra/Random.h>
50-
#include <hydra/detail/Copy.inl>
50+
#include <hydra/Algorithm.h>
5151

5252

5353
//hydra functions
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
/*----------------------------------------------------------------------------
2+
*
3+
* Copyright (C) 2016 - 2020 Antonio Augusto Alves Junior
4+
*
5+
* This file is part of Hydra Data Analysis Framework.
6+
*
7+
* Hydra is free software: you can redistribute it and/or modify
8+
* it under the terms of the GNU General Public License as published by
9+
* the Free Software Foundation, either version 3 of the License, or
10+
* (at your option) any later version.
11+
*
12+
* Hydra is distributed in the hope that it will be useful,
13+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
14+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15+
* GNU General Public License for more details.
16+
*
17+
* You should have received a copy of the GNU General Public License
18+
* along with Hydra. If not, see <http://www.gnu.org/licenses/>.
19+
*
20+
*---------------------------------------------------------------------------*/
21+
22+
/*
23+
* unweight_sample.cpp
24+
*
25+
* Created on: 21/10/2020
26+
* Author: Antonio Augusto Alves Junior
27+
*/
28+
29+
#include <examples/random/unweight_sample.inl>

0 commit comments

Comments
 (0)