@@ -26,6 +26,8 @@ def deleteDirWin() {
2626}
2727
2828def skipRemainingStages = false
29+ def runGpuAsync = false
30+ def openClGpuLabel = " gpu"
2931
3032def utils = new org.stan.Utils ()
3133
@@ -45,13 +47,10 @@ String stan_pr() { params.stan_pr ?: ( env.CHANGE_TARGET == "master" ? "downstre
4547pipeline {
4648 agent none
4749 parameters {
48- string(defaultValue : ' ' , name : ' cmdstan_pr' ,
49- description : ' PR to test CmdStan upstream against e.g. PR-630' )
50- string(defaultValue : ' ' , name : ' stan_pr' ,
51- description : ' PR to test Stan upstream against e.g. PR-630' )
52- booleanParam(defaultValue : false , description :
53- ' Run additional distribution tests on RowVectors (takes 5x as long)' ,
54- name : ' withRowVector' )
50+ string(defaultValue : ' ' , name : ' cmdstan_pr' , description : ' PR to test CmdStan upstream against e.g. PR-630' )
51+ string(defaultValue : ' ' , name : ' stan_pr' , description : ' PR to test Stan upstream against e.g. PR-630' )
52+ booleanParam(defaultValue : false , name : ' withRowVector' , description : ' Run additional distribution tests on RowVectors (takes 5x as long)' )
53+ booleanParam(defaultValue : false , name : ' gpu_async' , description : ' Run the OpenCL tests on both a sync (AMD) GPU and an async (NVIDIA) one.' )
5554 }
5655 options {
5756 skipDefaultCheckout()
@@ -150,13 +149,21 @@ pipeline {
150149 stage(' Verify changes' ) {
151150 agent { label ' linux' }
152151 steps {
153- script {
152+ script {
154153
155154 retry(3 ) { checkout scm }
156155 sh ' git clean -xffd'
157156
158157 def paths = [' stan' , ' make' , ' lib' , ' test' , ' runTests.py' , ' runChecks.py' , ' makefile' , ' Jenkinsfile' , ' .clang-format' ]. join(" " )
159158 skipRemainingStages = utils. verifyChanges(paths)
159+
160+ if (! utils. verifyChanges([" stan/math/opencl" , " test/unit/math/opencl" ]. join(" " )) || params. gpu_async){
161+ runGpuAsync = true
162+ openClGpuLabel = " gpu-no-async"
163+ }
164+ else {
165+ runGpuAsync = false
166+ }
160167 }
161168 }
162169 }
@@ -175,15 +182,29 @@ pipeline {
175182 }
176183 post { always { deleteDir() } }
177184 }
178- stage(' Linux Unit with MPI' ) {
179- agent { label ' linux && mpi' }
185+ stage(' Full Unit Tests' ) {
186+ agent any
187+ when {
188+ expression {
189+ ! skipRemainingStages
190+ }
191+ }
180192 steps {
181- deleteDir()
182- unstash ' MathSetup'
183- sh " echo CXX=${ MPICXX} >> make/local"
184- sh " echo CXX_TYPE=gcc >> make/local"
185- sh " echo STAN_MPI=true >> make/local"
186- runTests(" test/unit" )
193+ script {
194+ if (isUnix()) {
195+ deleteDir()
196+ unstash ' MathSetup'
197+ runTests(" test/unit/math/prim" )
198+ runTests(" test/unit/math/rev" )
199+ runTests(" test/unit" )
200+ } else {
201+ deleteDirWin()
202+ unstash ' MathSetup'
203+ runTestsWin(" test/unit/math/prim" )
204+ runTestsWin(" test/unit/math/rev" )
205+ runTestsWin(" test/unit" )
206+ }
207+ }
187208 }
188209 post { always { retry(3 ) { deleteDir() } } }
189210 }
@@ -194,8 +215,21 @@ pipeline {
194215 }
195216 }
196217 parallel {
197- stage(' Full unit with GPU' ) {
198- agent { label " gpu" }
218+ stage(' MPI tests' ) {
219+ agent { label ' linux && mpi' }
220+ steps {
221+ deleteDir()
222+ unstash ' MathSetup'
223+ sh " echo CXX=${ MPICXX} >> make/local"
224+ sh " echo CXX_TYPE=gcc >> make/local"
225+ sh " echo STAN_MPI=true >> make/local"
226+ runTests(" test/unit/math/prim/functor" )
227+ runTests(" test/unit/math/rev/functor" )
228+ }
229+ post { always { retry(3 ) { deleteDir() } } }
230+ }
231+ stage(' OpenCL tests' ) {
232+ agent { label openClGpuLabel }
199233 steps {
200234 deleteDir()
201235 unstash ' MathSetup'
@@ -204,7 +238,38 @@ pipeline {
204238 sh " echo OPENCL_PLATFORM_ID=0>> make/local"
205239 sh " echo OPENCL_DEVICE_ID=${ OPENCL_DEVICE_ID} >> make/local"
206240 sh " make -j${ env.PARALLEL} test-headers"
207- runTests(" test/unit" )
241+ runTests(" test/unit/math/opencl" )
242+ runTests(" test/unit/math/prim/fun/gp_exp_quad_cov_test" )
243+ runTests(" test/unit/math/prim/fun/mdivide_left_tri_test" )
244+ runTests(" test/unit/math/prim/fun/mdivide_right_tri_test" )
245+ runTests(" test/unit/math/prim/fun/multiply_test" )
246+ runTests(" test/unit/math/rev/fun/mdivide_left_tri_test" )
247+ runTests(" test/unit/math/rev/fun/multiply_test" )
248+ }
249+ post { always { retry(3 ) { deleteDir() } } }
250+ }
251+ stage(' OpenCL tests async' ) {
252+ agent { label " gpu-async" }
253+ when {
254+ expression {
255+ runGpuAsync
256+ }
257+ }
258+ steps {
259+ deleteDir()
260+ unstash ' MathSetup'
261+ sh " echo CXX=${ env.CXX} -Werror > make/local"
262+ sh " echo STAN_OPENCL=true>> make/local"
263+ sh " echo OPENCL_PLATFORM_ID=0>> make/local"
264+ sh " echo OPENCL_DEVICE_ID=${ OPENCL_DEVICE_ID} >> make/local"
265+ sh " make -j${ env.PARALLEL} test-headers"
266+ runTests(" test/unit/math/opencl" )
267+ runTests(" test/unit/math/prim/fun/gp_exp_quad_cov_test" )
268+ runTests(" test/unit/math/prim/fun/mdivide_left_tri_test" )
269+ runTests(" test/unit/math/prim/fun/mdivide_right_tri_test" )
270+ runTests(" test/unit/math/prim/fun/multiply_test" )
271+ runTests(" test/unit/math/rev/fun/mdivide_left_tri_test" )
272+ runTests(" test/unit/math/rev/fun/multiply_test" )
208273 }
209274 post { always { retry(3 ) { deleteDir() } } }
210275 }
@@ -238,13 +303,28 @@ pipeline {
238303 stage(' Threading tests' ) {
239304 agent any
240305 steps {
241- deleteDir()
242- unstash ' MathSetup'
243- sh " echo CXX=${ env.CXX} -Werror > make/local"
244- sh " echo CPPFLAGS+=-DSTAN_THREADS >> make/local"
245- runTests(" test/unit -f thread" )
246- sh " find . -name *_test.xml | xargs rm"
247- runTests(" test/unit -f map_rect" )
306+ script {
307+ if (isUnix()) {
308+ deleteDir()
309+ unstash ' MathSetup'
310+ sh " echo CXX=${ env.CXX} -Werror > make/local"
311+ sh " echo CPPFLAGS+=-DSTAN_THREADS >> make/local"
312+ sh " export STAN_NUM_THREADS=4"
313+ runTests(" test/unit -f thread" )
314+ sh " find . -name *_test.xml | xargs rm"
315+ runTests(" test/unit -f map_rect" )
316+ sh " find . -name *_test.xml | xargs rm"
317+ runTests(" test/unit -f reduce_sum" )
318+ } else {
319+ deleteDirWin()
320+ unstash ' MathSetup'
321+ bat " echo CXX=${ env.CXX} -Werror > make/local"
322+ bat " echo CXXFLAGS+=-DSTAN_THREADS >> make/local"
323+ runTestsWin(" test/unit -f thread" , false )
324+ runTestsWin(" test/unit -f map_rect" , false )
325+ runTestsWin(" test/unit -f reduce_sum" , false )
326+ }
327+ }
248328 }
249329 post { always { retry(3 ) { deleteDir() } } }
250330 }
@@ -258,21 +338,10 @@ pipeline {
258338 runTestsWin(" test/unit" , false )
259339 }
260340 }
261- stage(' Windows Threading' ) {
262- agent { label ' windows' }
263- steps {
264- deleteDirWin()
265- unstash ' MathSetup'
266- bat " echo CXX=${ env.CXX} -Werror > make/local"
267- bat " echo CXXFLAGS+=-DSTAN_THREADS >> make/local"
268- runTestsWin(" test/unit -f thread" )
269- runTestsWin(" test/unit -f map_rect" )
270- }
271- }
272341 }
273342 }
274343 stage(' Additional merge tests' ) {
275- when {
344+ when {
276345 allOf {
277346 anyOf {
278347 branch ' develop'
@@ -309,12 +378,12 @@ pipeline {
309378 }
310379 }
311380 stage(' Upstream tests' ) {
312- when {
381+ when {
313382 allOf {
314- expression {
315- env. BRANCH_NAME ==~ / PR-\d +/
383+ expression {
384+ env. BRANCH_NAME ==~ / PR-\d +/
316385 }
317- expression {
386+ expression {
318387 ! skipRemainingStages
319388 }
320389 }
0 commit comments