Reputation: 2 Apprentice
- Active Posts:
- 50 (0.03 per day)
- 18-February 10
- Profile Views:
- Last Active:
- Feb 27 2014 10:53 PM
- Dream Kudos:
Posts I've Made
Posted 4 Feb 2014
vector<vector <float> > m1 = *(new vector<vector<float> >(MAX_SIZE, vector<float>(MAX_SIZE)));
That is a truly bizarre memory leak, there.
vector<vector <float> > m1(MAX_SIZE, vector<float>(MAX_SIZE));
No reason other than having been babied in Java.
I like your version of the code. Much easier to read than what I had before. Use of typedef is new to me but easily understood.
Posted 2 Feb 2014Now as for you can do better than that advice... If instead using a vector of vectors, your allocated the memory as a flat array and just provided the appropriate accessors, you will very likely getting better performance because you'll get better cache locality. Even better, if you make the second matrix reverse the rows and columns, you'll get even better cache locality and improve the speed even more.
So something like making MAX_SIZE^2 size arrays? So [i][j] would be [i*MAX_SIZE + j]?
And reverse the second because m1[i][k]*m2[j][k] is faster than m1[i][k]*m2[k][j]?
Posted 2 Feb 2014Interesting. He explicitly stated not to do anything fancy optimization wise as that will be our next task, but now I'll know a couple of techniques to look into. I probably don't need to store the results in array since I'm not doing anything with them and I currently don't account for the changing of NUM_RUNS and MAX_SIZE.
Posted 2 Feb 2014Changed it to be a little more clear.
Posted 30 Nov 2013Indeed, not using a function seems to have fixed it.
That helps. Thank you.
- Member Title:
- New D.I.C Head
- Age Unknown
- Birthday Unknown
37Liion hasn't added any friends yet.