Dynamic memory allows users to allocate fast shared memory when a kernel
is launched. We used to support a single size for all kernels via the
LIBOMPTARGET_SHARED_MEMORY_SIZE environment variable but now we can
control it per kernel invocation and use computed values.
Note: Only the nextgen plugins will allocate memory based on the clause.
Try to use OMPD_task here and check if it works. I rather doubt you need to capture the expression and pass it to the target region. Also, check how device clause is implemented, most probably you need to do something similar. There is an implicit task created for nowait target, where need to allocate the space and pass the value.