Jump to content

  • Log In with Google      Sign In   
  • Create Account


#ActualSaruman

Posted 29 September 2012 - 08:01 PM

I think what he meant was having an array of structs where each one has five integers. If the data is not operated on in the same functions then you will be fetching structs of five ints, whereas if you kept a struct of related arrays instead than you would prefetch only the relevant data resulting in much less cache misses as you have left the cache warm.

For example:
[source lang="cpp"]struct Unit{ vec3 transform; int32 other_data; int32 more_data;};std::vector< Unit > units;[/source]
would perform much better as:
[source lang="cpp"]struct Units{ std::vector< vec3 > transforms; std::vector< int32 > other_datas; std::vector< int32 > more_datas;};[/source]

When doing something like say updating transformation matrices.. because instead of fetching other_data and more_data along with the transform like in the first example you are able to only fetch the needed transforms resulting in less cache misses.

#5Saruman

Posted 29 September 2012 - 08:01 PM

I think what he meant was having an array of structs where each one has five integers. If the data is not operated on in the same functions then you will be fetching structs of five ints, whereas if you kept a struct of related arrays instead than you could prefetch only the relevant data resulting in much less cache misses.

For example:
[source lang="cpp"]struct Unit{ vec3 transform; int32 other_data; int32 more_data;};std::vector< Unit > units;[/source]
would perform much better as:
[source lang="cpp"]struct Units{ std::vector< vec3 > transforms; std::vector< int32 > other_datas; std::vector< int32 > more_datas;};[/source]

When doing something like say updating transformation matrices.. because instead of fetching other_data and more_data along with the transform like in the first example you are able to only fetch the needed transforms resulting in less cache misses.

#4Saruman

Posted 29 September 2012 - 08:00 PM

I think what he meant was having an array of structs where each one has five integers. If the data is not operated on in the same functions then you will be fetching structs of five ints, whereas if you kept a struct of related arrays instead than you could prefetch only the relevant data resulting in much less cache misses.

For example:
[source lang="cpp"]struct Unit{ vec3 transform; int32 other_data; int32 more_data;};std::vector< Unit > units;[/source]
would perform much better as:
[source lang="cpp"]struct Units{ std::vector< vec3 > transforms; std::vector< int32 > other_datas; std::vector< int32 > more_datas;};[/source]
When doing something like say updating transformation matrices.. because instead of fetching other_data and more_data along with the transform like in the first example you are able to only fetch the needed transforms resulting in less cache misses.

#3Saruman

Posted 29 September 2012 - 08:00 PM

I think what he meant was having an array of structs where each one has five integers. If the data is not operated on in the same functions then you will be fetching structs of five ints, whereas if you kept a struct of related arrays instead than you could prefetch only the relevant data resulting in much less cache misses.

For example:
[source lang="cpp"]struct Unit{ vec3 transform; int32 other_data; int32 more_data; };std::vector<Unit> units;[/source]
would perform much better as:
[source lang="cpp"]struct Units{ std::vector<vec3> transforms; std::vector<int32> other_datas; std::vector<int32> more_datas;};[/source]
When doing something like say updating transformation matrices.. because instead of fetching other_data and more_data along with the transform like in the first example you are able to only fetch the needed transforms resulting in less cache misses.

#2Saruman

Posted 29 September 2012 - 07:54 PM

I think what he meant was having an array of structs where each one has five integers. If the data is not operated on in the same functions then you will be fetching structs of five ints, whereas if you kept a struct of related arrays instead than you could prefetch only the relevant data resulting in much less cache misses.

#1Saruman

Posted 29 September 2012 - 07:52 PM

I think what he meant was having an array of structs where each one has five integers. If the data is not operated on in the same functions then you will be fetching structs of five ints, whereas if you kept a struct of related arrays instead than you could prefetch only the relevant data resulting in much less cache misses depending on the data.

PARTNERS