【prime】sieve prime all algorithm/machine compare 各找素数算法/语言/硬件大比拼

AMD R5 5500U 2.1GHz 12线程

n单线程筛法( c language)kavehmz / prime( golang )kimwalisch/primesieve( c++ )CUDA
1e81.08s0.274s0.004s
1e914.8s2.3s0.03s
1e10memory can’t28.5s0.3s
1e11memory can’t183.3s3s
1e12memory can’t34s
1e13memory can’t473.658s

AMD EPYC 7K62 x2 2.6GHz192线程

n单线程筛法( c language)kavehmz / prime( golang )kimwalisch/primesieve( c++ )CUDA
1e80.99s0.005s
1e912s0.018s
1e10179.802s0.052s
1e114468.11s0.265s
1e12memory can’t2.501s
1e13memory can’t37s

c language:

void doprime(bool* prime)
{
	long long int n;
	bool t=true;

	setprime(2,prime);
	setprime(3,prime);
	n=1;

	while(n*n<max)
	{
		n=(t)?n+4:n+2;
		t=!t;
		if(!prime[n])
			continue;
		setprime(n,prime);
	}
}
gcc prime.c -O3 -o prime
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值