We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
We use marching squares/ tile based collision resolution, currently via branches.
The text was updated successfully, but these errors were encountered:
#include <vector> #include <iostream> #include <memory> #include <cmath> #include <iterator> inline void doSomeStuff(double & y, double x, int i) { y = std::cos(x); } inline void doSomeOtherStuff(double & y, double x, int i) { y = std::cos(x); } typedef void (*fptr) (double &, double, int); void doWork(std::vector<double> & x, std::vector<double> & y) { // vectorises for (int i = 0; i < 1024; i++) { //y[i] = std::sqrt(x[i]); nb sqrt requires -ffast-math doSomeStuff(y[i], x[i], i); } } void doWorkFptrs(std::vector<double> & x, std::vector<double> & y, std::vector<fptr> & fs) { // missed: couldn't vectorize loop // missed: statement clobbers memory: _2 (_8, _3, i_22); // missed: statement clobbers memory: _2 (_8, _3, i_22); for (int i = 0; i < 1024; i++) { fs[i](y[i], x[i], i); } } int main() { std::vector<fptr> work; std::vector<double> x; std::vector<double> y(0.0, 1024); for (unsigned i = 0; i < 1024; i++) { if (std::cos(i) > 0.0) { x.push_back(3.14159*std::sqrt(i)); } else { x.push_back(std::sqrt(i)); } i % 2 == 0 ? work.push_back(&doSomeStuff) : work.push_back(&doSomeOtherStuff); } doWork(x, y); for (unsigned i = 0; i < 1024; i++) { std::cout << y[i] << "\n"; } doWorkFptrs(x, y, work); for (unsigned i = 0; i < 1024; i++) { std::cout << y[i] << "\n"; } }
Sorry, something went wrong.
No branches or pull requests
We use marching squares/ tile based collision resolution, currently via branches.
The text was updated successfully, but these errors were encountered: