system
1
__double2loint,__hiloint2double 分别实现什么功能?
还有以下代码(SDK中的代码):
#define BEGIN_TIMING( )
{
unsigned int n_iterations;
for( n_iterations = 1; n_iterations < 0x80000000; n_iterations *= 2 )
{
Q( cudaThreadSynchronize( ) );
Q( cudaEventRecord( start, 0 ) );
for( unsigned int iteration = 0; iteration < n_iterations; iteration++ ){
#define END_TIMING( seconds ) }
Q( cudaEventRecord( end, 0 ) );
Q( cudaEventSynchronize( end ) );
float milliseconds;
Q( cudaEventElapsedTime( &milliseconds, start, end ) );
seconds = milliseconds/1e3f;
if( seconds >= TIMER_TOLERANCE )
break;
}
seconds /= n_iterations;
}
#define Q( condition ) {if( (condition) != 0 ) { printf( “\n FAILURE in %s, line %d\n”, FILE, LINE );exit( 1 );}}
每一行后面为什么都打一斜杠,是不是写错了
system
2
楼主您好:
关于您的3个问题:
(1)__double2loint()返回一个double的低32位。在我们的小尾机器上,这逻辑上等于:
double d = …;
int *p = (int *)&d;
int result = p[0];
(或者你使用union也可以)
(2)__hiloint2double()则将会组合2个4B的int成一个double,同样的逻辑上等于:
union
{
double d;
struct {int a; int b;};
}wch8802;
wch8802.a = …;
wch8802.b = …;
double result = wch8802.d;
(3)反斜杠是用来宏还没结束,下一行还有的,这样可以构建一个多行的宏。需要更多细节请参考CPP(C Pre-processor)说明(您可以购买ISO C99标准文档来学习的)。
感谢来访。
system
3
谢谢版主,以前发了个帖子是问__double2loint(),__hiloint2double()头文件是什么?您告诉我在#include<cuda_runtime.h>,可是我这个头文件已然加入,可是依然报错说 error : identifier “__double2loint” is undefined
error : identifier “__double2hiint” is undefined,error : identifier “__hiloint2double” is undefined这个怎么解决呢?
system
4
你看一下cuda_runtime.h 的头文件,看看里面有没有你要的这个功能就知道了。在toolkit–include里面
system
5
cuda_runtime.h还包含了许多头文件,对于包含的这些头文件我没查看,我只查看了cuda_runtime.h,确实没有。假如我想用到它,我应该加入什么头文件?
system
7
楼主您好,
使用cuda_runtime.h是正确的,
但是您还需要设置您的项目:
在贵项目属性上设计代码生成为您的实际计算能力,例如:compute_20,sm_20
这样您才可以__double2loint这样的函数。
如果您的卡很不幸的的确是计算能力1.0、1.1、1.2的这三种卡,那么很遗憾,您将不能使用该函数。
(只有至少1.3以上的才能用的)
如果真的是这种情况,建议升级贵卡。
感谢来访。