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

document starpu_execute_on_each_worker

Samuel Thibault 13 роки тому
батько
коміт
350ff7056f
1 змінених файлів з 20 додано та 5 видалено
  1. 20 5
      doc/starpu.texi

+ 20 - 5
doc/starpu.texi

@@ -2677,11 +2677,12 @@ starpu_mpi_gather_detached(data_handles, nblocks, 0, MPI_COMM_WORLD);
 @node Per-worker library initialization
 @section How to initialize a computation library once for each worker?
 
-Some libraries need to be initialized one for each concurrent instance that
+Some libraries need to be initialized once for each concurrent instance that
 may run on the machine. For instance, a C++ computation class which is not
 thread-safe by itself, but for which several instanciated objects of that class
 can be used concurrently. This can be used in StarPU by initializing one such
-object per worker. For instance, the libstarpufft example does the following to be able to use FFTW.
+object per worker. For instance, the libstarpufft example does the following to
+be able to use FFTW.
 
 Some global array stores the instanciated objects:
 
@@ -2715,9 +2716,23 @@ static void fft(void *descr[], void *_args)
 @}
 @end smallexample
 
-To also deal with the CUDA CUFFT implementation, the @code{fftw_plan} type can
-be replaced with a union of @code{fftw_plan} and @code{cufftHandle}, and the
-@code{switch} statement extended with @code{STARPU_CUDA_WORKER}.
+Another way to go which may be needed is to execute some code from the workers
+themselves thanks to @code{starpu_execute_on_each_worker}. This may be required
+by CUDA to behave properly due to threading issues. For instance, StarPU's
+@code{starpu_helper_cublas_init} looks like the following to call
+@code{cublasInit} from the workers themselves:
+
+@smallexample
+static void init_cublas_func(void *args STARPU_ATTRIBUTE_UNUSED)
+@{
+    cublasStatus cublasst = cublasInit();
+    cublasSetKernelStream(starpu_cuda_get_local_stream());
+@}
+void starpu_helper_cublas_init(void)
+@{
+    starpu_execute_on_each_worker(init_cublas_func, NULL, STARPU_CUDA);
+@}
+@end smallexample
 
 @c ---------------------------------------------------------------------
 @c Configuration options