Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <unistd.h>
- #define MAX_TITKOS 10000
- #define OLVASAS_BUFFER 256
- #define KULCS_MERET 4
- __global__
- void exor(int meret, char *temp)
- {
- char kulcs[KULCS_MERET];
- kulcs[0] = (char) (blockIdx.x + 48);
- kulcs[1] = (char) (threadIdx.x + 48);
- kulcs[2] = (char) (threadIdx.y + 48);
- for(int ii = '0'; ii <= '9'; ii++)
- {
- kulcs[3] = ii;
- printf("Kulcs: [%c%c%c%c]\n", kulcs[0], kulcs[1], kulcs[2], kulcs[3]);
- }
- }
- int main()
- {
- int olvasott_bajtok;
- char *titkos = new char[MAX_TITKOS];
- char *p = titkos;
- while ((olvasott_bajtok =
- read (0, (void *) p,
- (p - titkos + OLVASAS_BUFFER <
- MAX_TITKOS) ? OLVASAS_BUFFER : titkos + MAX_TITKOS - p)))
- p += olvasott_bajtok;
- int meret = p - titkos;
- for (int i = 0; i < MAX_TITKOS - meret; i++)
- titkos[meret + i] = '\0';
- char *temp;
- cudaMalloc((void**) &temp, meret);
- cudaMemcpy(temp, titkos, meret, cudaMemcpyHostToDevice );
- dim3 dimBlock(10, 10);
- exor<<<10, dimBlock>>>(meret, temp);
- cudaFree(temp);
- delete[] titkos;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement