How to use memory clobber when inline ptx

As indicated here (,
you can stop memory optimization adding the “memory”.

asm volatile (“add.f32 %0, %1, %2;” : “=f”(k) : “f”(i),“f”(j) :: “memory”);

But when compile the kernel, it reports the following.

error: expected a “)”

Any suggestions?

:: “memory”

should be

: “memory”

manual example

asm volatile ("mov.u32 %0, %%clock;" : "=r"(x) :: "memory")

employs “::” because it has no the “constraint”(input) part in the same way as here:

If there is no output operand, the colon separators are adjacent, e.g.:

asm("mov.s32 r1, %0;" :: "r"(i));

it also said right there:

you can add a "memory" clobbers specification after a <b><u>3rd colon</u></b>