-2

Is there any way to let the cpu handle some operations in PHP (quite like openCL) but is available in native php (without having PHP-openCL implemented)?

/E:

What i mean:

I am coding some php cli scripts

Everything you do in php (variables, etc.) will be cached in the ram. But you still can access the RAM directly (shmop - Link), which makes it way faster. (This is an example to access deep system resources, i just want to know if there are ways to access other deep system resources)

I want to acces the CPU directly for having speed up some operations by doing so. (in context of multithreading (pcntl_fork and running inside an endless while-loop in php cli script). Is there a way to skip the c-handler (dunno if this is the right expression).

OpenCL was just an example =)

Mohammer
  • 405
  • 3
  • 15
  • The CPU handles ***all*** operations in PHP anyway...‽‽‽ – deceze Nov 03 '12 at 21:38
  • This could be a complex question, but it's hard to answer as it's very open ended. What exactly are you trying to do? Are you trying to use openCL, or is that just an example? Remember that the CPU does everything for PHP anyway. – Rich Bradshaw Nov 03 '12 at 21:39
  • Take a look at my edit. i hope i gave every needed information to make my question understandable – Mohammer Nov 03 '12 at 22:21

1 Answers1

1

shmop is not "accessing memory directly" (it's sharing memory) and "bypassing the C layer" is not "accessing the CPU more directly".

The only thing that may remotely make sense is that you wish to code in ASM directly, instead of writing code in a higher level language which gets compiled down to machine code eventually. This is useful if you think you understand the CPU better than a C/PHP compiler and can write more efficient code for it (in your case, I'd have my doubts, to be honest). If so, you'll have to write an external application in said low-level language and invoke it from PHP. In C and some other languages you could write inline-ASM, but PHP doesn't support that.

deceze
  • 510,633
  • 85
  • 743
  • 889
  • Thank you, that's exactly the answer I was hoping for. By the way, your guessing was right (just wanted to know) – Mohammer Nov 03 '12 at 23:36