IMHO, you suggested we might require an `fence`  instructions to block the 
execution flow until data has been fully flushed back to DRAM. Therefore, I'm 
not quite sure do we really need `prologue`? 

If what we really need is just `epilogue` pragma, I think `barrier` might be a 
better name for it. A typical implement of the `barrier` looks like

```c
static void __attribute__((noinline)) barrier(int ncores)
{
  static volatile int sense;
  static volatile int count;
  static __thread int threadsense;

  __sync_synchronize();

  threadsense = !threadsense;
  if (__sync_fetch_and_add(&count, 1) == ncores-1)
  {
    count = 0;
    sense = threadsense;
  }
  else while(sense != threadsense)
    ;

  __sync_synchronize();
}
```
, which can be found at 
https://github.com/riscv/riscv-tests/blob/master/benchmarks/common/util.h#L44 .





---
[Visit 
Topic](https://discuss.tvm.ai/t/add-support-for-extern-prologue-epilogue-functions/6041/8)
 to respond.

You are receiving this because you enabled mailing list mode.

To unsubscribe from these emails, [click 
here](https://discuss.tvm.ai/email/unsubscribe/eb43edb7e8afa9b4693aeed95342d44a1ddfd403c43854651eaceab4f711086b).

Reply via email to