1// Copyright 2008 Google Inc. All Rights Reserved. 2 3// Licensed under the Apache License, Version 2.0 (the "License"); 4// you may not use this file except in compliance with the License. 5// You may obtain a copy of the License at 6 7// http://www.apache.org/licenses/LICENSE-2.0 8 9// Unless required by applicable law or agreed to in writing, software 10// distributed under the License is distributed on an "AS IS" BASIS, 11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12// See the License for the specific language governing permissions and 13// limitations under the License. 14 15#ifndef STRESSAPPTEST_ADLER32MEMCPY_H_ 16#define STRESSAPPTEST_ADLER32MEMCPY_H_ 17 18#include <string> 19#include "sattypes.h" 20 21// Encapsulation for Adler checksum. Please see adler32memcpy.cc for more 22// detail on the adler checksum algorithm. 23class AdlerChecksum { 24 public: 25 AdlerChecksum() {} 26 ~AdlerChecksum() {} 27 // Returns true if the checksums are equal. 28 bool Equals(const AdlerChecksum &other) const; 29 // Returns string representation of the Adler checksum 30 string ToHexString() const; 31 // Sets components of the Adler checksum. 32 void Set(uint64 a1, uint64 a2, uint64 b1, uint64 b2); 33 34 private: 35 // Components of Adler checksum. 36 uint64 a1_, a2_, b1_, b2_; 37 38 DISALLOW_COPY_AND_ASSIGN(AdlerChecksum); 39}; 40 41// Calculates Adler checksum for supplied data. 42bool CalculateAdlerChecksum(uint64 *data64, unsigned int size_in_bytes, 43 AdlerChecksum *checksum); 44 45// C implementation of Adler memory copy. 46bool AdlerMemcpyC(uint64 *dstmem64, uint64 *srcmem64, 47 unsigned int size_in_bytes, AdlerChecksum *checksum); 48 49// C implementation of Adler memory copy with some float point ops, 50// attempting to warm up the CPU. 51bool AdlerMemcpyWarmC(uint64 *dstmem64, uint64 *srcmem64, 52 unsigned int size_in_bytes, AdlerChecksum *checksum); 53 54// x86_64 SSE2 assembly implementation of fast and stressful Adler memory copy. 55bool AdlerMemcpyAsm(uint64 *dstmem64, uint64 *srcmem64, 56 unsigned int size_in_bytes, AdlerChecksum *checksum); 57 58 59#endif // STRESSAPPTEST_ADLER32MEMCPY_H_ 60