<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
<div dir="ltr">Yes, the name <span style="color:rgb(0,16,128);font-family:Menlo,Monaco,"Courier New",monospace;font-size:14px;white-space:pre-wrap">valid_GPU_array
</span>is very confusing. I read it as valid_places.<br clear="all">
<div>
<div dir="ltr" class="gmail_signature" data-smartmail="gmail_signature">
<div dir="ltr">--Junchao Zhang</div>
</div>
</div>
<br>
</div>
<br>
<div class="gmail_quote">
<div dir="ltr" class="gmail_attr">On Wed, Oct 2, 2019 at 1:12 AM Karl Rupp <<a href="mailto:rupp@iue.tuwien.ac.at">rupp@iue.tuwien.ac.at</a>> wrote:<br>
</div>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
Hi Junchao,<br>
<br>
I recall that Jed already suggested to make this a bitmask ~7 years ago ;-)<br>
<br>
On the other hand: If we touch valid_GPU_array, then we should also use <br>
a better name or refactor completely. Code like<br>
<br>
  (V->valid_GPU_array & PETSC_OFFLOAD_GPU)<br>
<br>
simply isn't intuitive (nor does it make sense) when read aloud.<br>
<br>
Best regards,<br>
Karli<br>
<br>
<br>
On 10/2/19 5:24 AM, Zhang, Junchao via petsc-dev wrote:<br>
> Stafano recently modified the following code,<br>
> <br>
> PetscErrorCode VecCreate_SeqCUDA(Vec V)<br>
> {<br>
>    PetscErrorCode ierr;<br>
> <br>
>    PetscFunctionBegin;<br>
>    ierr = PetscLayoutSetUp(V->map);CHKERRQ(ierr);<br>
>    ierr = VecCUDAAllocateCheck(V);CHKERRQ(ierr);<br>
>    ierr = <br>
> VecCreate_SeqCUDA_Private(V,((Vec_CUDA*)V->spptr)->GPUarray_allocated);CHKERRQ(ierr);<br>
>    ierr = VecCUDAAllocateCheckHost(V);CHKERRQ(ierr);<br>
>    ierr = VecSet(V,0.0);CHKERRQ(ierr);<br>
>    ierr = VecSet_Seq(V,0.0);CHKERRQ(ierr);<br>
> V->valid_GPU_array = PETSC_OFFLOAD_BOTH;<br>
> PetscFunctionReturn(0);<br>
> }<br>
> <br>
> That means if one creates an SEQCUDA vector V and then immediately tests <br>
> if (V->valid_GPU_array == PETSC_OFFLOAD_GPU), the test will fail. That <br>
> is counterintuitive.  I think we should have<br>
> <br>
>     enum {PETSC_OFFLOAD_UNALLOCATED=0x0,PETSC_OFFLOAD_GPU=0x1,PETSC_OFFLOAD_CPU=0x2,PETSC_OFFLOAD_BOTH=0x3}<br>
> <br>
> <br>
> and then use if (V->valid_GPU_array & PETSC_OFFLOAD_GPU). What do you think?<br>
> <br>
> --Junchao Zhang<br>
</blockquote>
</div>
</body>
</html>