How to do a progam about two "for" intructions parallel I need to do a parralel progr

I’m need to do a parallel program about to for a the same time

I’m think similar these but I dont now it that correct

#include <stdio.h>
#include <stdlib.h>
#include <cuda.h>

// Kernel definition
global void For_paralelo(char *result)
char letrero = “f1”;
int i = threadIdx.x;
int j = threadIdx.y;

for (i=1;i<1000;i++){
result[i] = *letrero;


for (j=1;j<2000;j++){}


int main(void)

dim3 dimBlock(1, 2);
char *device_result = 0;

// Kernel invocation

For_paralelo<<<1, dimBlock>>>(device_result);

return 0;


That won’t be parallel, it will be almost completely serial. You are launching one thread per block and each thread contains two serial for loops. That is about as far away from parallel as possible.

The CUDA paradigm isn’t like OpenMP or other shared memory parallel programming models. You really should spend some time reading the first couple of chapters of the CUDA programming guide, or work through some of the excellent free course material available on the web, like the U.Illinois CUDA programming course to familiarize yourself with how CUDA works.