Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add SIMD flags for runtime check #800

Merged
merged 3 commits into from
Dec 9, 2016
Merged

Conversation

gangliao
Copy link
Contributor

@gangliao gangliao commented Dec 9, 2016

No description provided.

using namespace paddle; // NOLINT

TEST(SIMDFlags, gccTest) {
#if (defined(__GNUC__) || defined(__GNUG__)) && !(defined(__clang__))
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

GCC可以用__builtin_cpu_supports对比一下

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

也许我们应该找几个奇怪的CPU试一下。。不知道我们是不是AMD CPU的机器。

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

确实应该找其他的CPU试一下。


static SIMDFlags* instance();

inline bool isSSE() { return simd_flags_ & SIMD_SSE; }
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

inline bool isSSE() const;
下同

using namespace paddle; // NOLINT

TEST(SIMDFlags, gccTest) {
#if (defined(__GNUC__) || defined(__GNUG__)) && !(defined(__clang__))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

也许我们应该找几个奇怪的CPU试一下。。不知道我们是不是AMD CPU的机器。

namespace paddle {

/// init simd instance
static InitFunction __init_simd_flags(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

另外,感觉起来,这里Lazy的Init也无所谓,不一定非要在main函数之前init吧。

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

#if (defined(__GNUC__) || defined(__GNUG__)) && !(defined(__clang__))
CHECK(__builtin_cpu_supports("sse") == HAS_SSE);
CHECK(__builtin_cpu_supports("sse2") == HAS_SSE2);
CHECK(__builtin_cpu_supports("sse3") == HAS_SSE3);
Copy link
Contributor Author

@gangliao gangliao Dec 9, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里写错了。__builtin_cpu_supports返回的值是positive number, 不一定是1或者true

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Copy link
Collaborator

@reyoung reyoung left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@gangliao gangliao merged commit 0cdfa8c into PaddlePaddle:develop Dec 9, 2016
@gangliao gangliao deleted the check_avx branch December 9, 2016 08:11

#pragma once

#include <iostream>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#include 这个用来做啥?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

之前还写了个os<<重载函数,删了之后,忘了删头文件了。


SIMDFlags();

static SIMDFlags* instance();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

instance()也可以返回const

#ifdef _WIN32

/// for MSVC
#define CPUID(info, x) __cpuidex(info, x, 0)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

_WIN32下不需要头文件?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok 我一起再改一下

zhhsplendid pushed a commit to zhhsplendid/Paddle that referenced this pull request Sep 25, 2019
gglin001 added a commit to graphcore/Paddle-fork that referenced this pull request Jun 20, 2022
qili93 pushed a commit that referenced this pull request Jun 21, 2022
* add argmin and argsort ops (#800)

* add argmin and arsort ops

* Add dot bmm ops (#803)

* add bmm

* add dot op

* clean CreateConst

* clean CreateCast

* add activation ops (#808)

* add activation ops

* fix 1function-redefined error
sneaxiy pushed a commit to sneaxiy/Paddle that referenced this pull request Jun 27, 2022
* add argmin and argsort ops (PaddlePaddle#800)

* add argmin and arsort ops

* Add dot bmm ops (PaddlePaddle#803)

* add bmm

* add dot op

* clean CreateConst

* clean CreateCast

* add activation ops (PaddlePaddle#808)

* add activation ops

* fix 1function-redefined error
yaozhixin pushed a commit to graphcore/Paddle-fork that referenced this pull request Jul 1, 2022
lizexu123 pushed a commit to lizexu123/Paddle that referenced this pull request Feb 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants