Переглянути джерело

- check that a CPU worker is available or return expected fail status

Olivier Aumage 9 роки тому
батько
коміт
340355c282

+ 8 - 0
examples/native_fortran/nf_matrix.f90

@@ -12,6 +12,7 @@ program nf_matrix
         type(c_ptr) :: dh_ma    ! a pointer for the 'ma' vector data handle
         type(c_ptr) :: dh_mb    ! a pointer for the 'mb' vector data handle
         integer(c_int) :: err   ! return status for fstarpu_init
+        integer(c_int) :: ncpu  ! number of cpus workers
 
         allocate(ma(5,6))
         do i=1,5
@@ -33,6 +34,13 @@ program nf_matrix
                 stop 77
         end if
 
+        ! stop there if no CPU worker available
+        ncpu = fstarpu_cpu_worker_get_count()
+        if (ncpu == 0) then
+                call fstarpu_shutdown()
+                stop 77
+        end if
+
         ! allocate an empty codelet structure
         cl_mat = fstarpu_codelet_allocate()
 

+ 8 - 0
examples/native_fortran/nf_vector.f90

@@ -27,6 +27,7 @@ program nf_vector
         type(c_ptr) :: dh_va    ! a pointer for the 'va' vector data handle
         type(c_ptr) :: dh_vb    ! a pointer for the 'vb' vector data handle
         integer(c_int) :: err   ! return status for fstarpu_init
+        integer(c_int) :: ncpu  ! number of cpus workers
 
         allocate(va(5))
         va = (/ (i,i=1,5) /)
@@ -40,6 +41,13 @@ program nf_vector
                 stop 77
         end if
 
+        ! stop there if no CPU worker available
+        ncpu = fstarpu_cpu_worker_get_count()
+        if (ncpu == 0) then
+                call fstarpu_shutdown()
+                stop 77
+        end if
+
         ! allocate an empty codelet structure
         cl_vec = fstarpu_codelet_allocate()