Server CPU and GPU With LAMP

10,134

Solution 1

PHP alone does not have the ability to leverage the GPU. This was recently discussed on the php internals developer list.

Keep in mind that GPUs excel at certain types of workloads, while they're not that great for others. PHP wouldn't be able to really take advantage of GPU acceleration because the work it performs isn't really the best kind for a GPU.

If you really want to play with HipHop and random high performance stuff, you might want to begin following Open Parallel. They've been working with an Intel technology called Threading Building Blocks and have been integrating it into HipHop by adding new functions that can call callbacks asynchronously, with outstanding results. There was a great deal of interest when they introduced their work to the HipHop group.

However, there is no sign whatsoever of CUDA support, or really any GPU support at all in HipHop. To be honest, HipHop is not the right solution for the majority of PHP users. If you are trying to squeeze performance out of code, you should be profiling it.

Solution 2

I wrote a compiler that translates a small subset of PHP to Futhark. The Futhark compiler can generate OpenCL and CUDA source code, so it could be used to run some PHP programs on a GPU.

This compiler is merely a proof-of-concept, but it can translate some relatively simple functions like this one:

function comma_string($a,$b){
    return $a . "," . $b;
}

The compiler generates this function in Futhark:

let comma_string a b = 
    a ++ "," ++ b

Alternatively, it might be possible to compile PHP to C using HipHop, and then compile it to SPIR-V using the SPIRV-LLVM-Translator.

Share:
10,134

Related videos on Youtube

GregL83
Author by

GregL83

Updated on May 05, 2022

Comments

  • GregL83
    GregL83 almost 2 years

    I am trying to figure out more about the hardware that can be utilized when running a php application or even a c++ compiled php app using HipHop. I would like to setup a microserver and use the GPU to help the CPU process requests...

    Anyone?

    • Tyler Eaves
      Tyler Eaves about 13 years
      GPU is worthless for anything that isn't low-precision floating point math. In a server environment it more cost and watt effective to just add more cpu(s) anyway.