小编Jon*_*hih的帖子

C pthread分段故障

所以我试图用c&pthreads制作GPGPU模拟器,但遇到了一个相当奇怪的问题,我不知道它为什么会发生.代码如下:

#include <stdlib.h>
#include <stdio.h>
#include <pthread.h>
#include <assert.h>

// simplifies malloc
#define MALLOC(a) (a *)malloc(sizeof(a))

// Index of x/y coordinate
#define x (0)
#define y (1)

// Defines size of a block
#define BLOCK_DIM_X (3)
#define BLOCK_DIM_Y (2)

// Defines size of the grid, i.e., how many blocks
#define GRID_DIM_X (5)
#define GRID_DIM_Y (7)

// Defines the number of threads in the grid
#define GRID_SIZE (BLOCK_DIM_X * BLOCK_DIM_Y * GRID_DIM_X * GRID_DIM_Y)

// execution environment for the kernel
typedef …
Run Code Online (Sandbox Code Playgroud)

c pthreads segmentation-fault

2
推荐指数
1
解决办法
1148
查看次数

标签 统计

c ×1

pthreads ×1

segmentation-fault ×1