help on memory bandwidth, programming


I was reading the example code in sdk. The following code section in the function testDeviceToDeviceTransfer(unsigned int memSize) puzzles me a little. Where does the factor 2.0f come from??

//calculate bandwidth in MB/s
bandwidthInMBs = 2.0f * (1e3f * memSize * (float)MEMCOPY_ITERATIONS) /
                                    (elapsedTimeInMs * (float)(1 << 20));

If you check corresponding section of other functions for device to host or host to device memory bandwidth measurement, they don’t have that factor of two …

Yo-Ming Hsieh

Why would they? The other transfers are unidirectional, DeviceToDevice is bidirectional because you are reading via the device’s memory interface and writing via the same interface.