有没有一种很好的方法来修改C++中的类,使其整数在64位系统上为64位,在32位系统上为32位?有没有办法检查?
这个类是这样的:
class B{
public:
int64_t size();
private:
int64_t m_size();
}
Run Code Online (Sandbox Code Playgroud) 我正在尝试在 C 中并行化光线跟踪器,但是随着线程数量的增加,执行时间并没有减少。我到目前为止的代码是:
main2(thread function):
float **result=malloc(width * sizeof(float*));
int count=0;
for (int px=0;, px<width; ++px)
{
...
for (int py=0; py<height; ++py)
{
...
float *scaled_color=malloc(3*sizeof(float));
scaled_color[0]=...
scaled_color[1]=...
scaled_color[2]=...
result[count]=scaled_color;
count++;
...
}
}
...
return (void *) result;
main:
pthread_t threads[nthreads];
for (i=0;i<nthreads;i++)
{
pthread_create(&threads[i], NULL, main2, &i);
}
float** result_handler;
for (i=0; i<nthreads; i++)
{
pthread_join(threads[i], (void *) &result_handler);
int count=0;
for(j=0; j<width;j++)
{
for(k=0;k<height;k++)
{
float* scaled_color=result_handler[count];
count ++;
printf...
}
printf("\n");
}
}
Run Code Online (Sandbox Code Playgroud)
main2 返回一个 …