how to tell whether any hit program is invoked

I did with rtPrintf() in the any hit program and closest hit program.
But there is no print.

But printf in intersection program and ray generation program works well.
rtPrintf in intersection program and ray generation program didn’t print.

I set

rtContextSetPrintEnabled(*context, 1 );
    rtContextSetPrintBufferSize( *context, 4096 );

You are not the first one on this forum to note problems with rtPrintf().

A better way to check if your any hit program is invoked could be to include a counter in your ray payload and increment it in the any hit program. You can then place the counter value into a buffer to return to the CPU at the end of ray traversal.