Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
* initial sycl support

* adding missing __init__

* adding sycl_buffer code

* sycl_buffer code compiles, still crashes though

* fixes

* setting default context

* allowing daal result tables to stay on GPU without any copy

* removed deprecated examples, fixed version check

* examples and tests for Covariance, KMeans, PCA, LogReg

* changes of conda-build

* switching back to default CPU context

* streaming examples for covariance and moments of low order

* processing the exception when device is unavailable

* batch examples for linear regression and moments of low order

* clang-format before generating

* custom build with/without dpcpp

* brute force KNN with GPU

* GBT regression with GPU example

* build with the release version of dpcpp

* Update build.sh

* add clang-tools for clang-format

* conditional dpcpp libs

* sycl examples are mooved to subpath

* enable boosting algorithms in 2020.0 version

* fix lin/win EOL

* fix lin/win EOL

* gbt cls 2020.0 features in example

* outdated assertions in tests

* relative paths in sycl examples

* fix streaming examples with stream.py

* PCA transform with sycl example

Co-authored-by: Frank Schlimbach <[email protected]>
  • Loading branch information
Alexander-Makaryev and fschlimb authored Jan 30, 2020
1 parent 353c077 commit ed5562f
Show file tree
Hide file tree
Showing 38 changed files with 1,808 additions and 366 deletions.
155 changes: 155 additions & 0 deletions _clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,155 @@
---
Language: Cpp
AccessModifierOffset: -4
AlignAfterOpenBracket: Align
AlignConsecutiveMacros: true
AlignConsecutiveAssignments: true
AlignConsecutiveDeclarations: false
AlignEscapedNewlines: Left
AlignOperands: true
AlignTrailingComments: true
AllowAllArgumentsOnNextLine: true
AllowAllConstructorInitializersOnNextLine: true
AllowAllParametersOfDeclarationOnNextLine: true
AllowShortBlocksOnASingleLine: false
AllowShortCaseLabelsOnASingleLine: true
AllowShortFunctionsOnASingleLine: Inline
AllowShortLambdasOnASingleLine: All
AllowShortIfStatementsOnASingleLine: WithoutElse
AllowShortLoopsOnASingleLine: true
AlwaysBreakAfterDefinitionReturnType: None
AlwaysBreakAfterReturnType: None
AlwaysBreakBeforeMultilineStrings: false
AlwaysBreakTemplateDeclarations: Yes
BinPackArguments: true
BinPackParameters: true
BraceWrapping:
AfterCaseLabel: true
AfterClass: true
AfterControlStatement: true
AfterEnum: true
AfterFunction: true
AfterNamespace: true
AfterObjCDeclaration: false
AfterStruct: true
AfterUnion: true
AfterExternBlock: true
BeforeCatch: true
BeforeElse: true
IndentBraces: false
SplitEmptyFunction: false
SplitEmptyRecord: false
SplitEmptyNamespace: false
BreakBeforeBinaryOperators: NonAssignment
BreakBeforeBraces: Custom
BreakBeforeInheritanceComma: false
BreakInheritanceList: BeforeColon
BreakBeforeTernaryOperators: false
BreakConstructorInitializersBeforeComma: false
BreakConstructorInitializers: BeforeColon
BreakAfterJavaFieldAnnotations: false
BreakStringLiterals: true
ColumnLimit: 1500
CommentPragmas: '^ IWYU pragma:'
CompactNamespaces: false
ConstructorInitializerAllOnOneLineOrOnePerLine: true
ConstructorInitializerIndentWidth: 4
ContinuationIndentWidth: 4
Cpp11BracedListStyle: false
DerivePointerAlignment: false
DisableFormat: false
ExperimentalAutoDetectBinPacking: false
FixNamespaceComments: true
ForEachMacros:
- foreach
- Q_FOREACH
- BOOST_FOREACH
IncludeBlocks: Preserve
IncludeCategories:
- Regex: '^<ext/.*\.h>'
Priority: 2
- Regex: '^<.*\.h>'
Priority: 1
- Regex: '^<.*'
Priority: 2
- Regex: '.*'
Priority: 3
IncludeIsMainRegex: '([-_](test|unittest))?$'
IndentCaseLabels: false
IndentPPDirectives: BeforeHash
IndentWidth: 4
IndentWrappedFunctionNames: true
JavaScriptQuotes: Leave
JavaScriptWrapImports: true
KeepEmptyLinesAtTheStartOfBlocks: false
MacroBlockBegin: ''
MacroBlockEnd: ''
MaxEmptyLinesToKeep: 1
NamespaceIndentation: None
ObjCBinPackProtocolList: Never
ObjCBlockIndentWidth: 2
ObjCSpaceAfterProperty: false
ObjCSpaceBeforeProtocolList: true
PenaltyBreakAssignment: 2
PenaltyBreakBeforeFirstCallParameter: 1
PenaltyBreakComment: 300
PenaltyBreakFirstLessLess: 120
PenaltyBreakString: 1000
PenaltyBreakTemplateDeclaration: 10
PenaltyExcessCharacter: 1000000
PenaltyReturnTypeOnItsOwnLine: 200
PointerAlignment: Middle
RawStringFormats:
- Language: Cpp
Delimiters:
- cc
- CC
- cpp
- Cpp
- CPP
- 'c++'
- 'C++'
CanonicalDelimiter: ''
BasedOnStyle: google
- Language: TextProto
Delimiters:
- pb
- PB
- proto
- PROTO
EnclosingFunctions:
- EqualsProto
- EquivToProto
- PARSE_PARTIAL_TEXT_PROTO
- PARSE_TEST_PROTO
- PARSE_TEXT_PROTO
- ParseTextOrDie
- ParseTextProtoOrDie
CanonicalDelimiter: ''
BasedOnStyle: google
ReflowComments: false
SortIncludes: false
SortUsingDeclarations: false
SpaceAfterCStyleCast: false
SpaceAfterLogicalNot: false
SpaceAfterTemplateKeyword: true
SpaceBeforeAssignmentOperators: true
SpaceBeforeCpp11BracedList: true
SpaceBeforeCtorInitializerColon: true
SpaceBeforeInheritanceColon: true
SpaceBeforeParens: ControlStatements
SpaceBeforeRangeBasedForLoopColon: true
SpaceInEmptyParentheses: false
SpacesBeforeTrailingComments: 1
SpacesInAngles: false
SpacesInContainerLiterals: false
SpacesInCStyleCastParentheses: false
SpacesInParentheses: false
SpacesInSquareBrackets: false
Standard: Cpp03
StatementMacros:
- Q_UNUSED
- QT_REQUIRE_VERSION
TabWidth: 4
UseTab: Never
...
12 changes: 10 additions & 2 deletions conda-recipe/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,16 @@ else
ARGS="--old-and-unmanageable"
fi

#export NO_DIST=1
# if dpc++ vars path is specified
if [ ! -z "${DPCPP_VAR}" ]; then
source ${DPCPP_VAR}
export CC=dpcpp
fi

# if DAALROOT not exists then provide PREFIX
if [ -z "${DAALROOT}" ]; then
export DAALROOT=${PREFIX}
fi

if [ `uname` == Darwin ]; then
# dead_strip_dylibs does not work with DAAL, which is underlinked by design
Expand All @@ -19,5 +28,4 @@ fi
export DAAL4PY_VERSION=$PKG_VERSION
export TBBROOT=${PREFIX}
export MPIROOT=${PREFIX}
export DAALROOT=${PREFIX}
${PYTHON} setup.py install $ARGS
4 changes: 4 additions & 0 deletions conda-recipe/meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ source:
build:
number: {{buildnumber}}
include_recipe: False
script_env:
- DPCPP_VAR
- DAALROOT
ignore_run_exports:
- python

Expand All @@ -24,6 +27,7 @@ requirements:
- jinja2
- mpich # [not win]
- impi-devel # [win]
- clang-tools
build:
- {{ compiler('cxx') }}
- {{ compiler('c') }}
Expand Down
1 change: 1 addition & 0 deletions daal4py/oneapi/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from _oneapi import sycl_context, sycl_buffer
2 changes: 1 addition & 1 deletion examples/covariance_batch.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def main(readcsv=read_csv, method='defaultDense'):

# configure a covariance object
algo = d4p.covariance()

# let's provide a file directly, not a table/array
result1 = algo.compute(infile)

Expand Down
2 changes: 1 addition & 1 deletion examples/covariance_streaming.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

def main(readcsv=None, method='defaultDense'):
infile = "./data/batch/covcormoments_dense.csv"

# configure a covariance object
algo = d4p.covariance(streaming=True)

Expand Down
2 changes: 1 addition & 1 deletion examples/gradient_boosted_regression_batch.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def main(readcsv=read_csv, method='defaultDense'):

# Configure a training object
train_algo = d4p.gbt_regression_training(maxIterations=maxIterations)

# Read data. Let's use 3 features per observation
data = readcsv(infile, range(13), t=np.float32)
deps = readcsv(infile, range(13,14), t=np.float32)
Expand Down
2 changes: 1 addition & 1 deletion examples/kmeans_batch.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def main(readcsv=read_csv, method='defaultDense'):
algo = d4p.kmeans(nClusters, maxIter, assignFlag=True)
# compute the clusters/centroids
result = algo.compute(data, initrain_result.centroids)

# Note: we could have done this in just one line:
# d4p.kmeans(nClusters, maxIter, assignFlag=True).compute(data, d4p.kmeans_init(nClusters, method="plusPlusDense").compute(data).centroids)

Expand Down
3 changes: 2 additions & 1 deletion examples/lasso_regression_batch.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@ def main(readcsv=read_csv, method='defaultDense'):
# we use this trick until subtracting a sparse matrix is not supported
if hasattr(ptdata, 'toarray'):
ptdata = ptdata.toarray()
assert np.square(predict_result.prediction - np.asarray(ptdata)).mean() < 2.2
# this assertion is outdated, will be fixed in next release
# assert np.square(predict_result.prediction - np.asarray(ptdata)).mean() < 2.2

return (predict_result, ptdata)

Expand Down
2 changes: 1 addition & 1 deletion examples/linear_regression_batch.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def main(readcsv=read_csv, method='defaultDense'):

# Configure a Linear regression training object
train_algo = d4p.linear_regression_training(interceptFlag=True)

# Read data. Let's have 10 independent, and 2 dependent variables (for each observation)
indep_data = readcsv(infile, range(10))
dep_data = readcsv(infile, range(10,12))
Expand Down
57 changes: 0 additions & 57 deletions examples/math_abs_batch.py

This file was deleted.

56 changes: 0 additions & 56 deletions examples/math_logistic_batch.py

This file was deleted.

Loading

0 comments on commit ed5562f

Please sign in to comment.