Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

97
Visualizações
How to implement a for loop inside a combineKernel in GPU.js

I'm new to gpu.js and I need help. Basically I want to access my two kernel functions but I don't know how without sacrificing the expense of calling createKernel each time. I know there is combineKernel but I haven't seen an example where it uses a for loop inside.

So I have my first function which generates a square matrix from a vector

const functionA = gpu.createKernel(function(vector:number[]) {
   // just body of the code
}).setOutput([somethingLength, somethingLength])

Then from the resulting square matrix, I add each of its columns, and this return a vector. So I have another function for that

const functionB = gpu.createKernel(function (squareMatrix: number[][], initialVector: number[]) {
        let sum = initialVector[this.thread.x]
        for (let i = 0; i < squareMatrixLength ; i++) {
            sum += squareMatrix[i][this.thread.x]
        }
        return sum;
}).setOutput([initialVector.length])

I also have a combineKernel for both of them

const functionC = gpu.combineKernels(functionA as any, functionB as any, function (initialVector: number[], vector: number[]) {
        return functionB(functionA(vector), initialVector)
    })

Now, I have a number of vectors that I want to undergo functionA and then functionB, I want to do something like the code below inside the combineKernel to avoid the expense of cpu to gpu but I am having trouble how to figure it out. I want the final result to be a 2D matrix.

for(let i=0; i<vectorsLength; i++){
   newVector = functionB(functionA(vectors[i]), initialVector)
}
return newVector
about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda