<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
<div dir="ltr">
<div>Stafano recently modified the following code,</div>
<div><br>
</div>
<div>
<div style="color:rgb(0,0,0);font-family:Menlo,Monaco,"Courier New",monospace;font-size:14px;line-height:21px;white-space:pre">
<div>PetscErrorCode <span style="color:rgb(121,94,38)">VecCreate_SeqCUDA</span>(Vec <span style="color:rgb(0,16,128)">V</span>)</div>
<div>{</div>
<div> PetscErrorCode ierr;</div>
<br>
<div> PetscFunctionBegin;</div>
<div> ierr = <span style="color:rgb(121,94,38)">PetscLayoutSetUp</span>(<span style="color:rgb(0,16,128)">V</span>-><span style="color:rgb(0,16,128)">map</span>);<span style="color:rgb(121,94,38)">CHKERRQ</span>(ierr);</div>
<div> ierr = <span style="color:rgb(121,94,38)">VecCUDAAllocateCheck</span>(V);<span style="color:rgb(121,94,38)">CHKERRQ</span>(ierr);</div>
<div> ierr = <span style="color:rgb(121,94,38)">VecCreate_SeqCUDA_Private</span>(V,((Vec_CUDA*)<span style="color:rgb(0,16,128)">V</span>-><span style="color:rgb(0,16,128)">spptr</span>)-><span style="color:rgb(0,16,128)">GPUarray_allocated</span>);<span style="color:rgb(121,94,38)">CHKERRQ</span>(ierr);</div>
<div> ierr = <span style="color:rgb(121,94,38)">VecCUDAAllocateCheckHost</span>(V);<span style="color:rgb(121,94,38)">CHKERRQ</span>(ierr);</div>
<div> ierr = <span style="color:rgb(121,94,38)">VecSet</span>(V,<span style="color:rgb(9,136,90)">0.0</span>);<span style="color:rgb(121,94,38)">CHKERRQ</span>(ierr);</div>
<div> ierr = <span style="color:rgb(121,94,38)">VecSet_Seq</span>(V,<span style="color:rgb(9,136,90)">0.0</span>);<span style="color:rgb(121,94,38)">CHKERRQ</span>(ierr);</div>
<div> <span style="color:rgb(0,16,128)">V</span>-><span style="color:rgb(0,16,128)">valid_GPU_array</span> = PETSC_OFFLOAD_BOTH;</div>
<div> <span style="color:rgb(121,94,38)">PetscFunctionReturn</span>(<span style="color:rgb(9,136,90)">0</span>);</div>
<div>}</div>
<div><br>
</div>
<div>That means if one creates an SEQCUDA vector V and then immediately tests if (<span style="color:rgb(0,16,128)">V</span>-><span style="color:rgb(0,16,128)">valid_GPU_array</span> == PETSC_OFFLOAD_GPU), the test will fail. That is
<span style="color:rgb(34,34,34);font-family:Roboto,arial,sans-serif;font-size:16px;white-space:normal">
counterintuitive. I think we should have</span></div>
</div>
</div>
<blockquote style="margin:0 0 0 40px;border:none;padding:0px">
<div>
<div style="color:rgb(0,0,0);font-family:Menlo,Monaco,"Courier New",monospace;font-size:14px;line-height:21px;white-space:pre">
<div>
<div style="line-height:21px">
<div><span style="color:rgb(0,0,255)">enum</span> {<span style="color:rgb(0,16,128)">PETSC_OFFLOAD_UNALLOCATED=0x0</span>,<span style="color:rgb(0,16,128)">PETSC_OFFLOAD_GPU=0x1</span>,<span style="color:rgb(0,16,128)">PETSC_OFFLOAD_CPU=0x2</span>,<span style="color:rgb(0,16,128)">PETSC_OFFLOAD_BOTH=0x3</span>} </div>
</div>
</div>
</div>
</div>
</blockquote>
<div>
<div style="color:rgb(0,0,0);font-family:Menlo,Monaco,"Courier New",monospace;font-size:14px;line-height:21px;white-space:pre">
<div style="line-height:21px">
<div>and then use if (<span style="color:rgb(0,16,128)">V</span>-><span style="color:rgb(0,16,128)">valid_GPU_array</span> & PETSC_OFFLOAD_GPU). What do you think?</div>
</div>
</div>
</div>
<br clear="all">
<div>
<div dir="ltr" class="gmail_signature" data-smartmail="gmail_signature">
<div dir="ltr">--Junchao Zhang</div>
</div>
</div>
</div>
</body>
</html>