Commits

Christos Kannas committed e685ba3

Update: Assign values to constant arrays.

Comments (0)

Files changed (1)

 
       C_Inline("/* Column compressed Stoichiometric matrix */");
       //C_Inline("%s double d_STOICM[NSTOICM] = STOICM;", CUDA_C_variable_qualifiers[1]);
-      C_Inline("%s double d_STOICM[%d] = {", CUDA_C_variable_qualifiers[1], nnz_stoicm);
-	  for(i = 0; i < nnz_stoicm; ++i){
-		C_Inline("\t%d,", stoicm[i]);
-	  }
-      C_Inline("};");
-      NewLines(1);
-	  
+      C_Inline("%s double d_STOICM[NSTOICM];", CUDA_C_variable_qualifiers[1]);
+
       //C_Inline("%s int d_CCOL_STOICM[CNEQN] = CCOL_STOICM;", CUDA_C_variable_qualifiers[1]);
-	  C_Inline("%s int d_CCOL_STOICM[%d] = {", CUDA_C_variable_qualifiers[1], EqnNr+1);
-	  for(i = 0; i <= EqnNr; ++i){
-		C_Inline("\t%d,", ccol_stoicm[i]);
-	  }
-      C_Inline("};");
-      NewLines(1);
+      C_Inline("%s int d_CCOL_STOICM[CNEQN];", CUDA_C_variable_qualifiers[1]);
 
       C_Inline("/* For each reaction equation find which species are used */");
       C_Inline("%s int Spc_Idx[%d] = {", CUDA_C_variable_qualifiers[1], (EqnNr * SpcNr));
       C_Inline("\tgpuMalloc((void **)&d_A, size);");
       C_Inline("\tcopyToGPU(size, RCT, d_Rct);");
       NewLines(1);
+      /* Copy data to constant device memory */
+      C_Inline("\tcudaMemcpyToSymbol(d_STOICM, STOICM, NSTOICM * sizeof(double), 0, cudaMemcpyHostToDevice);");
+      C_Inline("\tcudaMemcpyToSymbol(d_CCOL_STOICM, CCOL_STOICM, CNEQN * sizeof(int), 0, cudaMemcpyHostToDevice);");
       /* Execute */
       C_Inline("\t/* CUDA Kernels Execute*/");
       C_Inline("\tint threads = KPP_CUDA_THREAD_MAX;    // Threads per block, default 256");