LCOV - code coverage report
Current view: top level - tests/errorcheck - invalid_tasks.c (source / functions) Hit Total Coverage
Test: coverage.info Lines: 27 29 93.1 %
Date: 2013-05-17 Functions: 1 2 50.0 %
Branches: 4 8 50.0 %

           Branch data     Line data    Source code
       1                 :            : /* StarPU --- Runtime system for heterogeneous multicore architectures.
       2                 :            :  *
       3                 :            :  * Copyright (C) 2010-2012  Université de Bordeaux 1
       4                 :            :  * Copyright (C) 2010, 2011, 2012  Centre National de la Recherche Scientifique
       5                 :            :  *
       6                 :            :  * StarPU is free software; you can redistribute it and/or modify
       7                 :            :  * it under the terms of the GNU Lesser General Public License as published by
       8                 :            :  * the Free Software Foundation; either version 2.1 of the License, or (at
       9                 :            :  * your option) any later version.
      10                 :            :  *
      11                 :            :  * StarPU is distributed in the hope that it will be useful, but
      12                 :            :  * WITHOUT ANY WARRANTY; without even the implied warranty of
      13                 :            :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
      14                 :            :  *
      15                 :            :  * See the GNU Lesser General Public License in COPYING.LGPL for more details.
      16                 :            :  */
      17                 :            : 
      18                 :            : #include <starpu.h>
      19                 :            : #include "../helper.h"
      20                 :            : #include <common/config.h>
      21                 :            : 
      22                 :            : #if !defined(STARPU_HAVE_UNSETENV) || !defined(STARPU_USE_CPU)
      23                 :            : #warning unsetenv is not defined or no cpu are available. Skipping test
      24                 :            : int main(int argc, char **argv)
      25                 :            : {
      26                 :            :         return STARPU_TEST_SKIPPED;
      27                 :            : }
      28                 :            : #else
      29                 :            : 
      30                 :          0 : static void dummy_func(void *descr[], void *arg)
      31                 :            : {
      32                 :          0 : }
      33                 :            : 
      34                 :            : static struct starpu_codelet gpu_only_cl =
      35                 :            : {
      36                 :            :         .cuda_funcs = {dummy_func, NULL},
      37                 :            :         .opencl_funcs = {dummy_func, NULL},
      38                 :            :         .model = NULL,
      39                 :            :         .nbuffers = 0
      40                 :            : };
      41                 :            : 
      42                 :          1 : int main(int argc, char **argv)
      43                 :            : {
      44                 :            :         int ret;
      45                 :            : 
      46                 :            :         /* We force StarPU to use 1 CPU only */
      47                 :          1 :         unsetenv("STARPU_NCUDA");
      48                 :          1 :         unsetenv("STARPU_NOPENCL");
      49                 :          1 :         unsetenv("STARPU_NCPUS");
      50                 :            :         struct starpu_conf conf;
      51                 :          1 :         starpu_conf_init(&conf);
      52                 :          1 :         conf.ncpus = 1;
      53                 :          1 :         conf.nopencl = 0;
      54                 :          1 :         conf.ncuda = 0;
      55                 :            : 
      56                 :          1 :         ret = starpu_init(&conf);
      57         [ -  + ]:          1 :         if (ret == -ENODEV) return STARPU_TEST_SKIPPED;
      58         [ -  + ]:          1 :         STARPU_CHECK_RETURN_VALUE(ret, "starpu_init");
      59                 :            : 
      60                 :          1 :         struct starpu_task *task = starpu_task_create();
      61                 :          1 :         task->cl = &gpu_only_cl;
      62                 :            : 
      63                 :            :         /* Only a GPU device could execute that task ! */
      64                 :          1 :         ret = starpu_task_submit(task);
      65         [ -  + ]:          1 :         STARPU_ASSERT(ret == -ENODEV);
      66                 :            : 
      67                 :          1 :         task->destroy = 0;
      68                 :          1 :         starpu_task_destroy(task);
      69                 :            : 
      70                 :          1 :         struct starpu_task *task_specific = starpu_task_create();
      71                 :          1 :         task_specific->cl = &gpu_only_cl;
      72                 :          1 :         task_specific->execute_on_a_specific_worker = 1;
      73                 :          1 :         task_specific->workerid = 0;
      74                 :            : 
      75                 :            :         /* Only a CUDA device could execute that task ! */
      76                 :          1 :         ret = starpu_task_submit(task_specific);
      77         [ -  + ]:          1 :         STARPU_ASSERT(ret == -ENODEV);
      78                 :            : 
      79                 :          1 :         task_specific->destroy = 0;
      80                 :          1 :         starpu_task_destroy(task_specific);
      81                 :            : 
      82                 :          1 :         starpu_shutdown();
      83                 :            : 
      84                 :          1 :         return EXIT_SUCCESS;
      85                 :            : }
      86                 :            : #endif

Generated by: LCOV version 1.9