Skip to content

Commit

Permalink
+ Parmodelica: Fix array copy functions.
Browse files Browse the repository at this point in the history
  - Compile position independent on linux.
  - Disbale NVIDIA cache. 


git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@16091 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
mahge committed May 19, 2013
1 parent f42fe43 commit 3edb355
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 23 deletions.
6 changes: 3 additions & 3 deletions Compiler/Template/CodegenC.tpl
Expand Up @@ -5687,8 +5687,8 @@ template copyArrayDataAndFreeMemAfterCall(DAE.Type ty, String exp, DAE.Component
match context
case FUNCTION_CONTEXT(__) then
<<
copy_<%type%>_data(&<%exp%>, &<%cref%>);
<%if acceptParModelicaGrammar() then 'free_device_array(&<%exp%>);'%>
<%if not acceptParModelicaGrammar() then 'copy_<%type%>_data(&<%exp%>, &<%cref%>);'%>
<%if acceptParModelicaGrammar() then 'free_device_array(&<%cref%>); <%cref%> = <%exp%>;'%>
>>
case PARALLEL_FUNCTION_CONTEXT(__) then
'copy_<%type%>_data(&<%exp%>, &<%cref%>);'
Expand Down Expand Up @@ -5947,7 +5947,7 @@ case RANGE(__) then
let stepValue = match step case SOME(eo) then
daeExp(eo, context, &preExp, &varDecls)
else
"(1)"
"(modelica_integer)1"
let stopValue = daeExp(stop, context, &preExp, &varDecls)

let cl_kernelVar = tempDecl("cl_kernel", &varDecls)
Expand Down
2 changes: 1 addition & 1 deletion SimulationRuntime/ParModelica/OpenCLRuntime/Makefile.in
Expand Up @@ -2,7 +2,7 @@ CC=@CC@
CXX=@CXX@

CFLAGS=@CFLAGS@
CPPFLAGS=@CPPFLAGS@ -I. -I"../../c"
CPPFLAGS=@CPPFLAGS@ -I. -I"../../c" -fPIC

EXEEXT=
DLLEXT=.so
Expand Down
Expand Up @@ -118,7 +118,7 @@ function oclSetNumThreadsGlobalLocalError
external "builtin";
end oclSetNumThreadsGlobalLocalError;

function oclSetNumThreads = overload(
function oclSetNumThreads = $overload(
oclSetNumThreadsOnlyGlobal,
oclSetNumThreadsGlobalLocal1D,
oclSetNumThreadsGlobalLocal2D,
Expand Down
24 changes: 12 additions & 12 deletions SimulationRuntime/ParModelica/OpenCLRuntime/omc_ocl_interface.cpp
Expand Up @@ -164,53 +164,53 @@ void free_device_array(base_array_t* dest){



void copy_real_array_data(device_real_array* dev_array_ptr, real_array_t* host_array_ptr){
void copy_real_array(device_real_array* dev_array_ptr, real_array_t* host_array_ptr){

//Assert size of device array (dev array should be changed to struct later)
//Assert size of device array (dev array should be changed to struct later)
int nr_of_elm = modelica_array_nr_of_elements(host_array_ptr);
ocl_copy_back_to_host_real(dev_array_ptr->data, (modelica_real* )host_array_ptr->data, nr_of_elm);

}

void copy_real_array_data(real_array_t* host_array_ptr, device_real_array* dev_array_ptr){
void copy_real_array(real_array_t* host_array_ptr, device_real_array* dev_array_ptr){

//Assert size of device array (dev array should be changed to struct later)
//Assert size of device array (dev array should be changed to struct later)
//mahge: Fix here move this to copy function and add error check (like copy_back_to_host -> copy_to_device)
int nr_of_elm = modelica_array_nr_of_elements(host_array_ptr);
ocl_copy_to_device_real(dev_array_ptr->data, (modelica_real* )host_array_ptr->data, nr_of_elm);

}

void copy_real_array_data(device_real_array* dev_array_ptr1, device_real_array* dev_array_ptr2){
void copy_real_array(device_real_array* dev_array_ptr1, device_real_array* dev_array_ptr2){

//Assert size of device array (dev array should be changed to struct later)
//Assert size of device array (dev array should be changed to struct later)
//mahge: Fix here move this to copy function and add error check (like copy_back_to_host -> copy_to_device)
int nr_of_elm = device_array_nr_of_elements(dev_array_ptr1);
ocl_copy_device_to_device_real(dev_array_ptr1->data, dev_array_ptr2->data, nr_of_elm);

}

void copy_integer_array_data(device_integer_array* dev_array_ptr, integer_array_t* host_array_ptr){
void copy_integer_array(device_integer_array* dev_array_ptr, integer_array_t* host_array_ptr){

//Assert size of device array (dev array should be changed to struct later)
//Assert size of device array (dev array should be changed to struct later)
int nr_of_elm = modelica_array_nr_of_elements(host_array_ptr);
ocl_copy_back_to_host_integer(dev_array_ptr->data, (modelica_integer* )host_array_ptr->data, nr_of_elm);

}

void copy_integer_array_data(integer_array_t* host_array_ptr, device_integer_array* dev_array_ptr){
void copy_integer_array(integer_array_t* host_array_ptr, device_integer_array* dev_array_ptr){

//Assert size of device array
//Assert size of device array
//mahge: Fix here move this to copy function and add error check (like copy_back_to_host -> copy_to_device)
int nr_of_elm = modelica_array_nr_of_elements(host_array_ptr);
ocl_copy_to_device_integer(dev_array_ptr->data, (modelica_integer* )host_array_ptr->data, nr_of_elm);

}


void copy_integer_array_data(device_integer_array* dev_array_ptr1, device_integer_array* dev_array_ptr2){
void copy_integer_array(device_integer_array* dev_array_ptr1, device_integer_array* dev_array_ptr2){

//Assert size of device array (dev array should be changed to struct later)
//Assert size of device array (dev array should be changed to struct later)
//mahge: Fix here move this to copy function and add error check (like copy_back_to_host -> copy_to_device)
int nr_of_elm = device_array_nr_of_elements(dev_array_ptr1);
ocl_copy_device_to_device_integer(dev_array_ptr1->data, dev_array_ptr2->data, nr_of_elm);
Expand Down
12 changes: 6 additions & 6 deletions SimulationRuntime/ParModelica/OpenCLRuntime/omc_ocl_interface.h
Expand Up @@ -105,17 +105,17 @@ void alloc_integer_array(device_integer_array *dest, int ndims, ...);

void alloc_real_array(device_integer_array *dest, int ndims, ...);

void copy_real_array_data(device_real_array* dev_array_ptr, real_array_t* host_array_ptr);
void copy_real_array(device_real_array* dev_array_ptr, real_array_t* host_array_ptr);

void copy_real_array_data(real_array_t* host_array_ptr, device_real_array* dev_array_ptr);
void copy_real_array(real_array_t* host_array_ptr, device_real_array* dev_array_ptr);

void copy_real_array_data(device_real_array* dev_array_ptr1, device_real_array* dev_array_ptr2);
void copy_real_array(device_real_array* dev_array_ptr1, device_real_array* dev_array_ptr2);

void copy_integer_array_data(device_integer_array* dev_array_ptr, integer_array_t* host_array_ptr);
void copy_integer_array(device_integer_array* dev_array_ptr, integer_array_t* host_array_ptr);

void copy_integer_array_data(integer_array_t* host_array_ptr, device_integer_array* dev_array_ptr);
void copy_integer_array(integer_array_t* host_array_ptr, device_integer_array* dev_array_ptr);

void copy_integer_array_data(device_integer_array* dev_array_ptr1, device_integer_array* dev_array_ptr2);
void copy_integer_array(device_integer_array* dev_array_ptr1, device_integer_array* dev_array_ptr2);


//functions used for copying scalars. Scalars in the normal(serial C) code genertation
Expand Down
2 changes: 2 additions & 0 deletions SimulationRuntime/ParModelica/OpenCLRuntime/omc_ocl_util.cpp
Expand Up @@ -195,6 +195,8 @@ void ocl_initialize(){
ocl_create_context_and_comm_queue();
ocl_build_p_from_src();
}

setenv("CUDA_CACHE_DISABLE", "1", 1);
}

void ocl_create_context_and_comm_queue(){
Expand Down

0 comments on commit 3edb355

Please sign in to comment.