Open sakehl opened 3 months ago
I've always imagined that this was implicit in the contract. Like you say, this contract is not satisfiable unless all dimensions other than blockDim.x
are 1. I'm curious why there is an == 2
in the satcheck and why the assert doesn't error, maybe the first explains the second.
I see I never responded to this.
I'm pretty sure the 'griddimX == 2' is from a viper file that comes from a different cuda file, where I made the dimensions more specific, but is still wrong. Thus the == 2
is there from a different reason.
So this version corresponds with the viper code:
//:: cases BasicCuda
//:: tool silicon
//:: verdict Pass
#include <cuda.h>
/*@
context_everywhere blockDim.x > 0 && blockDim.y == 1 && blockDim.z == 1;
context_everywhere gridDim.x == 2 && gridDim.y == 1 && gridDim.z == 1;
context a != NULL && \pointer_length(a)>blockDim.x;
context Perm(&a[threadIdx.x], write);
@*/
__global__ void example(int a[], int len) {
int tid = threadIdx.x;
a[tid] = tid;
/*@
context Perm(&a[threadIdx.x], write);
@*/
__syncthreads();
a[tid] = a[tid] * 2;
}`
So this file:
from
examples/concepts/gpgpu/cuda.cu
is actually wrong. Because we threadIdx.x is not unique, each block in x, y and z direction all have write permission.
(so we have
gridDim.x*gridDim.y*gridDim.z*blockDim.y*blockDim.z*write
permission actually)But the method that checks if the pre-condition is satisfiable does not work here:
if we remove the
scale1
function from the write, it actually does realize this is not satisfiable.This is the correct version:
Already discussed this with @pieter-bos before, but
scale
breaks more things it seems.