/* StarPU --- Runtime system for heterogeneous multicore architectures. * * Copyright (C) 2011, 2012, 2013, 2014 CNRS * * StarPU is free software; you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or (at * your option) any later version. * * StarPU is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * * See the GNU Lesser General Public License in COPYING.LGPL for more details. */ #include #include #include #include "../helper.h" void func_cpu(void *descr[], void *_args) { int num = STARPU_TASK_GET_NBUFFERS(starpu_task_get_current()); int i; for (i = 0; i < num; i++) { int *x = (int *)STARPU_VARIABLE_GET_PTR(descr[i]); *x = *x + 1; } } struct starpu_codelet codelet = { .cpu_funcs = {func_cpu}, /* starpu_task_get_current() doesn't work on MIC */ /* .cpu_funcs_name = {"func_cpu"}, */ .nbuffers = STARPU_VARIABLE_NBUFFERS, }; struct starpu_codelet codelet_minus1 = { .cpu_funcs = {func_cpu}, /* starpu_task_get_current() doesn't work on MIC */ /* .cpu_funcs_name = {"func_cpu"}, */ .nbuffers = STARPU_NMAXBUFS-1, }; struct starpu_codelet codelet_plus5 = { .cpu_funcs = {func_cpu}, /* starpu_task_get_current() doesn't work on MIC */ /* .cpu_funcs_name = {"func_cpu"}, */ .nbuffers = STARPU_NMAXBUFS+5, }; int main(int argc, char **argv) { int *x; int i, ret, loop; #ifdef STARPU_QUICK_CHECK int nloops = 4; #else int nloops = 16; #endif starpu_data_handle_t *data_handles; struct starpu_data_descr *descrs; unsigned *expected; ret = starpu_init(NULL); if (ret == -ENODEV) return STARPU_TEST_SKIPPED; STARPU_CHECK_RETURN_VALUE(ret, "starpu_init"); x = calloc(STARPU_NMAXBUFS+5, sizeof(*x)); data_handles = malloc((STARPU_NMAXBUFS+5) * sizeof(*data_handles)); descrs = malloc((STARPU_NMAXBUFS+5) * sizeof(*descrs)); expected = calloc(STARPU_NMAXBUFS+5, sizeof(*expected)); for(i=0 ; i 1 /* Same with static number of buffers in codelet */ expected[0]++; for (i = 1; i < STARPU_NMAXBUFS-1; i++) expected[i]++; ret = starpu_task_insert(&codelet_minus1, STARPU_RW, data_handles[0], STARPU_DATA_MODE_ARRAY, &descrs[1], STARPU_NMAXBUFS-2, 0); if (ret == -ENODEV) goto enodev; STARPU_CHECK_RETURN_VALUE(ret, "starpu_task_insert"); #endif /* Test a whole array bigger than NMAXBUFS */ for (i = 0; i < STARPU_NMAXBUFS+5; i++) expected[i]++; ret = starpu_task_insert(&codelet, STARPU_DATA_MODE_ARRAY, descrs, STARPU_NMAXBUFS+5, 0); if (ret == -ENODEV) goto enodev; STARPU_CHECK_RETURN_VALUE(ret, "starpu_task_insert"); /* Same with static number of buffers in codelet */ for (i = 0; i < STARPU_NMAXBUFS+5; i++) expected[i]++; ret = starpu_task_insert(&codelet_plus5, STARPU_DATA_MODE_ARRAY, descrs, STARPU_NMAXBUFS+5, 0); if (ret == -ENODEV) goto enodev; STARPU_CHECK_RETURN_VALUE(ret, "starpu_task_insert"); /* Test a whole array after one data, and bigger than NMAXBUFS */ for (i = 0; i < STARPU_NMAXBUFS+5; i++) expected[i]++; ret = starpu_task_insert(&codelet, STARPU_RW, data_handles[0], STARPU_DATA_MODE_ARRAY, &descrs[1], STARPU_NMAXBUFS+4, 0); if (ret == -ENODEV) goto enodev; STARPU_CHECK_RETURN_VALUE(ret, "starpu_task_insert"); /* Same with static number of buffers in codelet */ for (i = 0; i < STARPU_NMAXBUFS+5; i++) expected[i]++; ret = starpu_task_insert(&codelet_plus5, STARPU_RW, data_handles[0], STARPU_DATA_MODE_ARRAY, &descrs[1], STARPU_NMAXBUFS+4, 0); if (ret == -ENODEV) goto enodev; STARPU_CHECK_RETURN_VALUE(ret, "starpu_task_insert"); /* Test datas one after the other, but less than NMAXBUFS */ expected[0]++; for (i = 1; i < STARPU_NMAXBUFS-1 && i < 10; i++) expected[i]++; ret = starpu_task_insert(&codelet, STARPU_RW, data_handles[0], #if STARPU_NMAXBUFS > 2 STARPU_RW, data_handles[1], #endif #if STARPU_NMAXBUFS > 3 STARPU_RW, data_handles[2], #endif #if STARPU_NMAXBUFS > 4 STARPU_RW, data_handles[3], #endif #if STARPU_NMAXBUFS > 5 STARPU_RW, data_handles[4], #endif #if STARPU_NMAXBUFS > 6 STARPU_RW, data_handles[5], #endif #if STARPU_NMAXBUFS > 7 STARPU_RW, data_handles[6], #endif #if STARPU_NMAXBUFS > 8 STARPU_RW, data_handles[7], #endif #if STARPU_NMAXBUFS > 9 STARPU_RW, data_handles[8], #endif #if STARPU_NMAXBUFS > 10 STARPU_RW, data_handles[9], #endif 0); if (ret == -ENODEV) goto enodev; STARPU_CHECK_RETURN_VALUE(ret, "starpu_task_insert"); #if STARPU_NMAXBUFS > 1 && STARPU_NMAXBUFS <= 8 /* Same with static number of buffers in codelet */ expected[0]++; for (i = 1; i < STARPU_NMAXBUFS-1 && i < 7; i++) expected[i]++; ret = starpu_task_insert(&codelet_minus1, STARPU_RW, data_handles[0], #if STARPU_NMAXBUFS > 2 STARPU_RW, data_handles[1], #endif #if STARPU_NMAXBUFS > 3 STARPU_RW, data_handles[2], #endif #if STARPU_NMAXBUFS > 4 STARPU_RW, data_handles[3], #endif #if STARPU_NMAXBUFS > 5 STARPU_RW, data_handles[4], #endif #if STARPU_NMAXBUFS > 6 STARPU_RW, data_handles[5], #endif #if STARPU_NMAXBUFS > 7 STARPU_RW, data_handles[6], #endif 0); if (ret == -ENODEV) goto enodev; STARPU_CHECK_RETURN_VALUE(ret, "starpu_task_insert"); #endif /* Test datas one after the other, but less than NMAXBUFS */ for (i = 0; i < STARPU_NMAXBUFS+5 && i < 10; i++) expected[i]++; ret = starpu_task_insert(&codelet, STARPU_RW, data_handles[0], STARPU_RW, data_handles[1], STARPU_RW, data_handles[2], STARPU_RW, data_handles[3], STARPU_RW, data_handles[4], STARPU_RW, data_handles[5], #if STARPU_NMAXBUFS > 1 STARPU_RW, data_handles[6], #endif #if STARPU_NMAXBUFS > 2 STARPU_RW, data_handles[7], #endif #if STARPU_NMAXBUFS > 3 STARPU_RW, data_handles[8], #endif #if STARPU_NMAXBUFS > 4 STARPU_RW, data_handles[9], #endif 0); if (ret == -ENODEV) goto enodev; STARPU_CHECK_RETURN_VALUE(ret, "starpu_task_insert"); #if STARPU_NMAXBUFS > 1 && STARPU_NMAXBUFS <= 8 /* Same with static number of buffers in codelet*/ for (i = 0; i < STARPU_NMAXBUFS+5 && i < 13; i++) expected[i]++; ret = starpu_task_insert(&codelet_plus5, STARPU_RW, data_handles[0], STARPU_RW, data_handles[1], STARPU_RW, data_handles[2], STARPU_RW, data_handles[3], STARPU_RW, data_handles[4], STARPU_RW, data_handles[5], #if STARPU_NMAXBUFS > 1 STARPU_RW, data_handles[6], #endif #if STARPU_NMAXBUFS > 2 STARPU_RW, data_handles[7], #endif #if STARPU_NMAXBUFS > 3 STARPU_RW, data_handles[8], #endif #if STARPU_NMAXBUFS > 4 STARPU_RW, data_handles[9], #endif #if STARPU_NMAXBUFS > 5 STARPU_RW, data_handles[10], #endif #if STARPU_NMAXBUFS > 6 STARPU_RW, data_handles[11], #endif #if STARPU_NMAXBUFS > 7 STARPU_RW, data_handles[12], #endif 0); if (ret == -ENODEV) goto enodev; STARPU_CHECK_RETURN_VALUE(ret, "starpu_task_insert"); #endif } enodev: for(i=0 ; i