Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-devel / 2016-10

A generic function for (multicore) cache flush?

11 messages · 8 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Nikolai Zhubr

Hello all,

Is there any good generic (portable) function to ensure memory cache flush for a thread on a multicore system?

What I'm trying to do is essentially fetch some debugging counters from multiple threads. They might happen to run on separate cores, thus having something pending in local cache sometimes. I would like to avoid EnterCriticalSection/ LeaveCriticalSection as such blocking would be a huge overkill, however it is still desireable to fetch reasonably current values. I'd like to avoid doing manual assembly as well (for portability reasons etc.).

Thanks a lot!

Nikolai

Reply by email

Jeppe Johansen
to Nikolai Zhubr
Nikolai Zhubr wrote 17 lines
Hello all, Is there any good generic (portable) function to ensure memory cache flush for a thread on a multicore system? What I'm trying to do is essentially fetch some debugging counters from multiple threads. They might happen to run on separate cores, thus having something pending in local cache sometimes. I would like to avoid EnterCriticalSection/ LeaveCriticalSection as such blocking would be a huge overkill, however it is still desireable to fetch reasonably current values. I'd like to avoid doing manual assembly as well (for portability reasons etc.). Thanks a lot! Nikolai

Have you found this to be a problem in real environments? I can't imagine any of the mainstream processor architectures of FPC where you wouldn't expect normal coherent bus operation when just reading cached memory from other processors. If all you need is just reasonably recent values that is..

Reply by email

Gennady Agranov
to Jeppe Johansen

Hi,

I have an issue with loading JNI library for Raspberry :(

I do compile with -Cg -WX and stack checking on (and also without).

But even this method is not called :(

function JNI_OnLoad(vm: PJavaVM; reserved: pointer): jint; {$ifdef
linux}cdecl{$else}stdcall{$endif};
begin
   writeln('lll');
   exit(0);
end;

Any suggestions?

Thanks,
Gennady

Java HotSpot(TM) Client VM warning: You have loaded library /media/pi/Transcend/cypress-release/pas2jni_policing64/policing64/policing.so which might have disabled stack guard. The VM will try to fix the stack guard now.

It's highly recommended that you fix the library with 'execstack -c <libfile>', or link it with '-z noexecstack'.

[FORMS.PP] ExceptionOccurred

Sender=EStackOverflow

Exception=Stack overflow

Stack trace:

$62E6CF48 fpc_stackcheck, line 832 of
/home/pi/development/fpc/rtl/inc/system.inc

TApplication.HandleException Stack overflow

Stack trace:

$62E6CF48 fpc_stackcheck, line 832 of
/home/pi/development/fpc/rtl/inc/system.inc

Exception at 62E6CF48: EStackOverflow:

Stack overflow.

Reply by email

Nikolai Zhubr
to Jeppe Johansen: Have you found this to be a problem in real environments? I can't imagine any of the…

31.10.2016 22:44, Jeppe Johansen:

Show quoted text 16 lines
> Is there any good generic (portable) function to ensure memory cache > flush for a thread on a multicore system? > > What I'm trying to do is essentially fetch some debugging counters > from multiple threads. They might happen to run on separate cores, > thus having something pending in local cache sometimes. I would like > to avoid EnterCriticalSection/ LeaveCriticalSection as such blocking > would be a huge overkill, however it is still desireable to fetch > reasonably current values. I'd like to avoid doing manual assembly as > well (for portability reasons etc.). > > > Thanks a lot! > > Nikolai Have you found this to be a problem in real environments?

No.

I can't imagine any of the mainstream processor architectures of FPC where you wouldn't expect normal coherent bus operation when just reading cached memory from other processors. If all you need is just reasonably recent values that is..

Ok. Probably you are right.
Thanks!

Nikolai

Reply by email

Mark Morgan Lloyd
to Nikolai Zhubr: Is there any good generic (portable) function to ensure memory cache flush for a thread…
Nikolai Zhubr wrote 8 lines
Hello all, Is there any good generic (portable) function to ensure memory cache flush for a thread on a multicore system? What I'm trying to do is essentially fetch some debugging counters from multiple threads. They might happen to run on separate cores, thus having something pending in local cache sometimes.

Surely that shouldn't happen on a properly-implemented cache-coherent system?

Mark Morgan Lloyd markMLl .AT. telemetry.co .DOT. uk [Opinions above are the author's, not those of his employers or colleagues]

Reply by email

Unknown author
to Gennady Agranov: I have an issue with loading JNI library for Raspberry :( I do compile with -Cg -WX and…
Gennady Agranov wrote
Hi, I have an issue with loading JNI library for Raspberry :(

what does this have to do with the "A generic function for (multicore) cache flush?" topic you attached it to by replying to that topic? you should use the [write] or [post] button and then type in the name of the mailing list or news group... then the subject and the post instead of trying to take shortcuts and hijacking a topic...

NOTE: No off-list assistance is given without prior approval. *Please keep mailing list traffic on the list* unless private contact is specifically requested and granted.

Reply by email

Gennady Agranov
to Unknown author

I thought that "reply" and changing the subject to a new one will do the trick...

Is "topic" stored somewhere in the mail headers?

Sorry,
Gennady

Show quoted text 11 lines
On 10/31/2016 04:01 PM, Gennady Agranov wrote: > Hi, > > I have an issue with loading JNI library for Raspberry :( what does this have to do with the "A generic function for (multicore) cache flush?" topic you attached it to by replying to that topic? you should use the [write] or [post] button and then type in the name of the mailing list or news group... then the subject and the post instead of trying to take shortcuts and hijacking a topic...

Reply by email

Yury Sidorov
to Gennady Agranov: I have an issue with loading JNI library for Raspberry :( I do compile with -Cg -WX and…
Gennady Agranov wrote 28 lines
I have an issue with loading JNI library for Raspberry :( I do compile with -Cg -WX and stack checking on (and also without). But even this method is not called :( function JNI_OnLoad(vm: PJavaVM; reserved: pointer): jint; {$ifdef linux}cdecl{$else}stdcall{$endif}; begin writeln('lll'); exit(0); end; Any suggestions? Thanks, Gennady Java HotSpot(TM) Client VM warning: You have loaded library /media/pi/Transcend/cypress-release/pas2jni_policing64/policing64/policing.so which might have disabled stack guard. The VM will try to fix the stack guard now. It's highly recommended that you fix the library with 'execstack -c <libfile>', or link it with '-z noexecstack'. [FORMS.PP] ExceptionOccurred

Why do you use LCL in your JNI library?
Try a simple library without LCL and check if it loads. Also do not add any extra compiler switches.
In FPC 3.0 -Cg is broken for ARM.

Yury.

Reply by email