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

[WIP] Expose OpenCL optimization pass #1353

Draft
wants to merge 20 commits into
base: master
Choose a base branch
from
Draft
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
89 changes: 86 additions & 3 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def tagName() {
}
}

def runPerformanceTests(String testsPath, String stancFlags = ""){
def runPerformanceTests(String testsPath, String stancFlags = "", Boolean opencl = false){
unstash 'ubuntu-exe'

sh """
Expand All @@ -37,7 +37,6 @@ def runPerformanceTests(String testsPath, String stancFlags = ""){
utils.checkout_pr("cmdstan", "performance-tests-cmdstan/cmdstan", params.cmdstan_pr)
utils.checkout_pr("stan", "performance-tests-cmdstan/cmdstan/stan", params.stan_pr)
utils.checkout_pr("math", "performance-tests-cmdstan/cmdstan/stan/lib/stan_math", params.math_pr)

sh """
cd performance-tests-cmdstan
mkdir cmdstan/bin
Expand All @@ -48,7 +47,14 @@ def runPerformanceTests(String testsPath, String stancFlags = ""){
if (stancFlags?.trim()) {
sh "cd performance-tests-cmdstan/cmdstan && echo 'STANCFLAGS= $stancFlags' >> make/local"
}

if (opencl) {
sh """
cd performance-tests-cmdstan/cmdstan
echo STAN_OPENCL=true >> make/local
echo OPENCL_PLATFORM_ID=${OPENCL_PLATFORM_ID_GPU} >> make/local
echo OPENCL_DEVICE_ID=${OPENCL_DEVICE_ID_GPU} >> make/local
"""
}
sh """
cd performance-tests-cmdstan/cmdstan
echo 'O=0' >> make/local
Expand Down Expand Up @@ -82,6 +88,11 @@ pipeline {
GIT_AUTHOR_EMAIL = '[email protected]'
GIT_COMMITTER_NAME = 'Stan Jenkins'
GIT_COMMITTER_EMAIL = '[email protected]'
OPENCL_DEVICE_ID_CPU = 0
OPENCL_DEVICE_ID_GPU = 0
OPENCL_PLATFORM_ID = 1
OPENCL_PLATFORM_ID_CPU = 0
OPENCL_PLATFORM_ID_GPU = 0
}
stages {
stage('Kill previous builds') {
Expand Down Expand Up @@ -401,7 +412,79 @@ pipeline {
}
post { always { runShell("rm -rf ${env.WORKSPACE}/compile-example-O1/*") }}
}
stage("Compile tests - good with opencl and O=1") {
when {
beforeAgent true
allOf {
expression {
!skipCompileTestsAtO1
}
expression {
!params.skip_compile_O1
}
}
}
agent {
docker {
image 'stanorg/ci:gpu'
label 'linux'
}
}
steps {
dir("${env.WORKSPACE}/compile-good-O1cl"){
unstash "Stanc3Setup"
script {
runPerformanceTests("../test/integration/good", "--O1 --use-opencl", true)
}

xunit([GoogleTest(
deleteOutputFiles: false,
failIfNotNew: true,
pattern: 'performance-tests-cmdstan/performance.xml',
skipNoTestFiles: false,
stopProcessingIfError: false)
])
}
}
post { always { runShell("rm -rf ${env.WORKSPACE}/compile-good-O1cl/*") }}
}

stage("Compile tests - example-models with opencl and O=1") {
when {
beforeAgent true
allOf {
expression {
!skipCompileTestsAtO1
}
expression {
!params.skip_compile_O1
}
}
}
agent {
docker {
image 'stanorg/ci:gpu'
label 'linux'
}
}
steps {
dir("${env.WORKSPACE}/compile-example-O1cl"){
script {
unstash "Stanc3Setup"
runPerformanceTests("example-models", "--O1 --use-opencl", true)
}

xunit([GoogleTest(
deleteOutputFiles: false,
failIfNotNew: true,
pattern: 'performance-tests-cmdstan/performance.xml',
skipNoTestFiles: false,
stopProcessingIfError: false)
])
}
}
post { always { runShell("rm -rf ${env.WORKSPACE}/compile-example-O1cl/*") }}
}
stage("Model end-to-end tests") {
when {
beforeAgent true
Expand Down
6 changes: 3 additions & 3 deletions src/analysis_and_optimization/Debug_data_generation.ml
Original file line number Diff line number Diff line change
Expand Up @@ -264,8 +264,8 @@ and gen_tuple m st t =

and generate_value m st t =
match st with
| SizedType.SInt -> Expr.Helpers.int (gen_num_int m t)
| SReal -> Expr.Helpers.float (gen_num_real m t)
| SizedType.SInt _ -> Expr.Helpers.int (gen_num_int m t)
| SReal _ -> Expr.Helpers.float (gen_num_real m t)
| SComplex -> gen_complex ()
| SVector (_, e) -> gen_vector m (unwrap_int_exn m e) t
| SRowVector (_, e) -> gen_row_vector m (unwrap_int_exn m e) t
Expand All @@ -275,7 +275,7 @@ and generate_value m st t =
| SComplexRowVector e -> gen_complex_row_vector (unwrap_int_exn m e)
| SComplexMatrix (e1, e2) ->
gen_complex_matrix (unwrap_int_exn m e1) (unwrap_int_exn m e2)
| SArray (st, e) -> gen_array m st (unwrap_int_exn m e) t
| SArray (_, st, e) -> gen_array m st (unwrap_int_exn m e) t
| STuple _ -> gen_tuple m st t

let generate_expressions input data =
Expand Down
Loading