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

reformat code etc. #1

Merged
merged 5 commits into from
Mar 4, 2022
Merged
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
66 changes: 66 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
# Generated from CLion C/C++ Code Style settings
BasedOnStyle: LLVM
AccessModifierOffset: -4
AlignAfterOpenBracket: Align
AlignConsecutiveAssignments: None
AlignOperands: Align
AllowAllArgumentsOnNextLine: false
AllowAllConstructorInitializersOnNextLine: false
AllowAllParametersOfDeclarationOnNextLine: false
AllowShortBlocksOnASingleLine: Always
AllowShortCaseLabelsOnASingleLine: false
AllowShortFunctionsOnASingleLine: All
AllowShortIfStatementsOnASingleLine: Always
AllowShortLambdasOnASingleLine: All
AllowShortLoopsOnASingleLine: true
AlwaysBreakAfterReturnType: None
AlwaysBreakTemplateDeclarations: Yes
BreakBeforeBraces: Custom
BraceWrapping:
AfterCaseLabel: false
AfterClass: false
AfterControlStatement: Never
AfterEnum: false
AfterFunction: false
AfterNamespace: false
AfterUnion: false
BeforeCatch: false
BeforeElse: false
IndentBraces: false
SplitEmptyFunction: false
SplitEmptyRecord: true
BreakBeforeBinaryOperators: None
BreakBeforeTernaryOperators: true
BreakConstructorInitializers: BeforeColon
BreakInheritanceList: BeforeColon
ColumnLimit: 0
CompactNamespaces: false
ContinuationIndentWidth: 8
IndentCaseLabels: true
IndentPPDirectives: None
IndentWidth: 2
KeepEmptyLinesAtTheStartOfBlocks: true
MaxEmptyLinesToKeep: 2
NamespaceIndentation: All
ObjCSpaceAfterProperty: false
ObjCSpaceBeforeProtocolList: true
PointerAlignment: Right
ReflowComments: false
SpaceAfterCStyleCast: true
SpaceAfterLogicalNot: false
SpaceAfterTemplateKeyword: false
SpaceBeforeAssignmentOperators: true
SpaceBeforeCpp11BracedList: false
SpaceBeforeCtorInitializerColon: true
SpaceBeforeInheritanceColon: true
SpaceBeforeParens: ControlStatements
SpaceBeforeRangeBasedForLoopColon: false
SpaceInEmptyParentheses: false
SpacesBeforeTrailingComments: 0
SpacesInAngles: false
SpacesInCStyleCastParentheses: false
SpacesInContainerLiterals: false
SpacesInParentheses: false
SpacesInSquareBrackets: false
TabWidth: 4
UseTab: Never
2 changes: 1 addition & 1 deletion .github/workflows/autoTest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ name: CI
on:
# Triggers the workflow on push or pull request events but only for the main branch
push:
branches: [ main ]
branches: [ '*' ]
pull_request:
branches: [ main ]

Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
.*.sw*
*.root
cmake-build*
.idea
88 changes: 40 additions & 48 deletions include/goofit/PDFs/GooPdf.h
Original file line number Diff line number Diff line change
@@ -1,88 +1,80 @@
#ifndef THRUST_PDF_FUNCTOR_HH
#define THRUST_PDF_FUNCTOR_HH
#include <cmath>
#include "goofit/PdfBase.h"
#include <cmath>

#define CALLS_TO_PRINT 10


EXEC_TARGET int dev_powi(int base, int exp);// Implemented in SmoothHistogramPdf.
void *getMetricPointer(std::string name);

EXEC_TARGET int dev_powi(int base, int exp); // Implemented in SmoothHistogramPdf.
void* getMetricPointer(std::string name);

typedef fptype (*device_function_ptr)(fptype *, fptype *,
unsigned int *);// Pass event, parameters, index into parameters.
typedef fptype (*device_metric_ptr)(fptype, fptype *, unsigned int);

typedef fptype(*device_function_ptr)(fptype*, fptype*,
unsigned int*); // Pass event, parameters, index into parameters.
typedef fptype(*device_metric_ptr)(fptype, fptype*, unsigned int);
extern void *host_fcn_ptr;

extern void* host_fcn_ptr;

EXEC_TARGET fptype callFunction(fptype* eventAddress, unsigned int functionIdx, unsigned int paramIdx);
EXEC_TARGET fptype callFunction(fptype *eventAddress, unsigned int functionIdx, unsigned int paramIdx);

class MetricTaker;
class BinnedMetricTaker;

class GooPdf : public PdfBase {
public:

GooPdf(Variable* x, std::string n);
public:
GooPdf(Variable *x, std::string n);
__host__ virtual double calculateNLL() const;
__host__ void evaluateAtPoints(std::vector<fptype>& points) const;
__host__ void evaluateAtPoints(Variable* var, std::vector<fptype>& res);
__host__ double evaluateAtPoints(const std::vector<double> &v);
__host__ void evaluateAtPoints(Variable *var, std::vector<fptype> &res);


__host__ virtual fptype normalise() const;
__host__ virtual fptype integrate(__attribute__((unused)) fptype lo, __attribute__((unused)) fptype hi) const {return 0;}
__host__ virtual fptype integrate(__attribute__((unused)) fptype lo, __attribute__((unused)) fptype hi) const { return 0; }


__host__ virtual bool hasAnalyticIntegral() const {return false;}
__host__ virtual bool hasAnalyticIntegral() const { return false; }


__host__ fptype getValue();
__host__ void getCompProbsAtDataPoints(std::vector<std::vector<fptype> >& values);
__host__ void initialise(std::vector<unsigned int> pindices, void* dev_functionPtr = host_fcn_ptr);
__host__ void scan(Variable* var, std::vector<fptype>& values);
__host__ virtual void setFitControl(FitControl* const fc, bool takeOwnerShip = true);
__host__ fptype getValue();
__host__ void getCompProbsAtDataPoints(std::vector<std::vector<fptype>> &values);
__host__ void initialise(std::vector<unsigned int> pindices, void *dev_functionPtr = host_fcn_ptr);
__host__ void scan(Variable *var, std::vector<fptype> &values);
__host__ virtual void setFitControl(FitControl *const fc, bool takeOwnerShip = true);
__host__ bool IsChisquareFit() const;
__host__ virtual void setMetrics();
__host__ virtual void setMetrics();
__host__ void setParameterConstantness(bool constant = true);

__host__ virtual void transformGrid(fptype* host_output);
static __host__ int findFunctionIdx(void* dev_functionPtr);
__host__ virtual void transformGrid(fptype *host_output);
static __host__ int findFunctionIdx(void *dev_functionPtr);

__host__ void debug() const;

protected:
__host__ virtual double sumOfNll(int numVars) const;
MetricTaker* logger; // for calculating Nll
BinnedMetricTaker* binnedlogger; // for calculating Nll
protected:
__host__ virtual double sumOfNll(int numVars) const;
MetricTaker *logger; // for calculating Nll
BinnedMetricTaker *binnedlogger;// for calculating Nll
};

class MetricTaker : public thrust::unary_function<thrust::tuple<int, fptype*, int>, fptype> {
class MetricTaker : public thrust::unary_function<thrust::tuple<int, fptype *, int>, fptype> {
public:

MetricTaker(PdfBase* dat, void* dev_functionPtr);
EXEC_TARGET fptype operator()(thrust::tuple<int, fptype*, int> t) const; // Event number, dev_event_array(pass this way for nvcc reasons), event size
MetricTaker(PdfBase *dat, void *dev_functionPtr);
EXEC_TARGET fptype operator()(thrust::tuple<int, fptype *, int> t) const;// Event number, dev_event_array(pass this way for nvcc reasons), event size

private:

unsigned int metricIndex; // Function-pointer index of processing function, eg logarithm, chi-square, other metric.
unsigned int functionIdx; // Function-pointer index of actual PDF
unsigned int parameters;

};
class BinnedMetricTaker : public thrust::unary_function<thrust::tuple<int, int, fptype*>, fptype> {
unsigned int metricIndex;// Function-pointer index of processing function, eg logarithm, chi-square, other metric.
unsigned int functionIdx;// Function-pointer index of actual PDF
unsigned int parameters;
};
class BinnedMetricTaker : public thrust::unary_function<thrust::tuple<int, int, fptype *>, fptype> {
public:

BinnedMetricTaker(PdfBase* dat, void* dev_functionPtr);
EXEC_TARGET fptype operator()(thrust::tuple<int, int, fptype*> t) const; // Event number, event size, low/up/n
BinnedMetricTaker(PdfBase *dat, void *dev_functionPtr);
EXEC_TARGET fptype operator()(thrust::tuple<int, int, fptype *> t) const;// Event number, event size, low/up/n

private:

unsigned int metricIndex; // Function-pointer index of processing function, eg logarithm, chi-square, other metric.
unsigned int functionIdx; // Function-pointer index of actual PDF
unsigned int parameters;

};
unsigned int metricIndex;// Function-pointer index of processing function, eg logarithm, chi-square, other metric.
unsigned int functionIdx;// Function-pointer index of actual PDF
unsigned int parameters;
};

#endif
Loading