From c210fae87d70134830fd7966ad7eff6bcf3fa4d0 Mon Sep 17 00:00:00 2001 From: stamoor <stamoor@f3b2605a-c512-4ea7-a41b-209d697bcdaa> Date: Thu, 9 Jul 2015 22:46:55 +0000 Subject: [PATCH] Fixing Kokkos memory bug git-svn-id: svn://svn.icms.temple.edu/lammps-ro/trunk@13566 f3b2605a-c512-4ea7-a41b-209d697bcdaa --- src/KOKKOS/memory_kokkos.h | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/src/KOKKOS/memory_kokkos.h b/src/KOKKOS/memory_kokkos.h index 5097936ba2..034fbca239 100644 --- a/src/KOKKOS/memory_kokkos.h +++ b/src/KOKKOS/memory_kokkos.h @@ -173,7 +173,10 @@ TYPE create_kokkos(TYPE &data, typename TYPE::value_type **&array, bigint n = 0; for (int i = 0; i < n1; i++) { - array[i] = &data.h_view(i,0); + if(n2==0) + array[i] = NULL; + else + array[i] = &data.h_view(i,0); n += n2; } return data; @@ -195,7 +198,10 @@ template <typename TYPE, typename HTYPE> bigint n = 0; for (int i = 0; i < n1; i++) { - array[i] = &h_data(i,0); + if(n2==0) + array[i] = NULL; + else + array[i] = &h_data(i,0); n += n2; } return data; @@ -216,7 +222,10 @@ TYPE grow_kokkos(TYPE &data, typename TYPE::value_type **&array, array = (typename TYPE::value_type**) srealloc(array,nbytes,name); for (int i = 0; i < n1; i++) - array[i] = &data.h_view(i,0); + if(n2==0) + array[i] = NULL; + else + array[i] = &data.h_view(i,0); return data; } @@ -230,7 +239,10 @@ TYPE create_kokkos(TYPE &data, typename TYPE::value_type **&array, array = (typename TYPE::value_type **) smalloc(nbytes,name); for (int i = 0; i < n1; i++) - array[i] = &data.h_view(i,0); + if(data.h_view.dimension_1()==0) + array[i] = NULL; + else + array[i] = &data.h_view(i,0); return data; } @@ -247,7 +259,10 @@ TYPE grow_kokkos(TYPE &data, typename TYPE::value_type **&array, array = (typename TYPE::value_type **) smalloc(nbytes,name); for (int i = 0; i < n1; i++) - array[i] = &data.h_view(i,0); + if(data.h_view.dimension_1()==0) + array[i] = NULL; + else + array[i] = &data.h_view(i,0); return data; } -- GitLab