Compare commits

..

No commits in common. "d1343ff90c5fe1f85feede69173af9efb2a3e631" and "bbed99ba8c89a0c233ec914fbd9e07b72796262f" have entirely different histories.

6 changed files with 37 additions and 93 deletions

View file

@ -1 +1 @@
clang++ -DDEBUG src\proto\proto.cpp -o build\ayo.exe -Wall -Wextra -Wpedantic -std=c++11 -g -gcodeview -Wl,-pdb= -L C:\capybara\libclang\x86_64-w64-mingw32\bin -static-libstdc++ -static --verbose clang++ -DDEBUG src\proto\proto.cpp -o build\ayo.exe -Wall -Wextra -Wpedantic -std=c++11 -g -gcodeview -Wl,-pdb= -L C:\capybara\libclang\x86_64-w64-mingw32\bin -l c++ -l unwind -static --verbose

View file

@ -1,3 +1,7 @@
<<<<<<< Updated upstream
=======
//si, bueno, testx
>>>>>>> Stashed changes
/* /*
* THREADIN THE LINUS: https://linux.die.net/man/2/sched_setaffinity * THREADIN THE LINUS: https://linux.die.net/man/2/sched_setaffinity
*/ */
@ -25,7 +29,7 @@ Intel(R) 64 and IA-32 Architectures Software Developer's Manual Volume 3 (3A, 3B
//TSC is incremented by the base multiplier once every reference clock, so on my Xeon E5-2680 (Sandy Bridge EP) this is an increment of 27 every 10 ns //TSC is incremented by the base multiplier once every reference clock, so on my Xeon E5-2680 (Sandy Bridge EP) this is an increment of 27 every 10 ns
//https://github.com/jdmccalpin/low-overhead-timers/issues/1
#ifdef _WIN64 #ifdef _WIN64
//#include <Windows.h> //#include <Windows.h>
@ -41,7 +45,7 @@ Intel(R) 64 and IA-32 Architectures Software Developer's Manual Volume 3 (3A, 3B
#include <stringapiset.h> #include <stringapiset.h>
#include <synchapi.h> #include <synchapi.h>
#endif #endif
#ifdef LOwOnus #ifdef NOMESELDELINUS
//hilitos y tal //hilitos y tal
#endif #endif
@ -49,17 +53,6 @@ Intel(R) 64 and IA-32 Architectures Software Developer's Manual Volume 3 (3A, 3B
#include <iostream> #include <iostream>
#include "../debug.h" #include "../debug.h"
uint64_t checksatr(){ //Generic
uint64_t rcx;
asm volatile (".intel_syntax noprefix\t\n" \
"mov eax, 0x80000007\t\n" \
// 080000007h\t\n"
"cpuid\t\n" : "=c" (rcx) );
//bool iTSC = rcx & (1<<6);
//"and edx, 10000000\n")
return rcx;
}
bool checkInvariantTSC(){ //Generic bool checkInvariantTSC(){ //Generic
uint64_t rdx; uint64_t rdx;
asm volatile (".intel_syntax noprefix\t\n" \ asm volatile (".intel_syntax noprefix\t\n" \
@ -103,11 +96,10 @@ EDX Bits 31-00: Reserved = 0.
*/ */
char* AMDTest() { char* AMDMeCagoEnTusPutosMuertos () {
/* /*
* Extended name on AMD systems when using 8000_002-4. 8000_0000 for Extpagequant/vendor. Hijos de puta. * Extended name on AMD systems when using 8000_002-4. 8000_0000 for Extpagequant/vendor. Hijos de puta.
* Now parsing 0H for standard brand name * Now parsing 0H for standard brand name
* https://github.com/jdmccalpin/low-overhead-timers/issues/1
*/ */
char* palabritas = (char*)malloc(sizeof(char) * 13); char* palabritas = (char*)malloc(sizeof(char) * 13);
uint8_t siguienteLetra = 0; uint8_t siguienteLetra = 0;
@ -127,8 +119,8 @@ char* AMDTest() {
return palabritas; return palabritas;
} }
//GMET on??????????? Zenbros... //GMET on??????????? jfc wtf
bool AMDGMET(){ bool AMDJoderMET(){
uint64_t rdx; uint64_t rdx;
asm volatile ( ".intel_syntax noprefix\t\n" \ asm volatile ( ".intel_syntax noprefix\t\n" \
"mov eax, 0x8000000A\t\n" \ "mov eax, 0x8000000A\t\n" \
@ -256,7 +248,7 @@ uint64_t estimandoFreq(){
valLen = MAX_VALUE_NAME; valLen = MAX_VALUE_NAME;
//data NULL + len NON_NULL to get dataBufLen; //data NULL + len NON_NULL to get dataBufLen;
//data allocated (NON-NULL) + len NON-NULL with previous value for dataLen //data allocated (NON-NULL) + len NON-NULL with previous value for dataLen
//MS WHY. that why we defaultin to biggis. cos not worky. ewe //JFC MS WHY. that why we defaultin to biggis. cos not worky. ewe
dataLen = sizeof(REG_QWORD) * (longestDataSize); dataLen = sizeof(REG_QWORD) * (longestDataSize);
status = RegEnumValueW(key, status = RegEnumValueW(key,
i, i,
@ -286,7 +278,9 @@ uint64_t estimandoFreq(){
) )
) { ) {
//dataLen = dataLen * 2lu; //dataLen = dataLen * 2lu;
/* We do be usin' well designed APIs...... /* BROS YO ES QUE ME VOY A CAGAR EN SUS PUTOS MUERTOS
* AS&iacute; QUE PIDES DOS VECES, UNA TAMA&nacute;O, OTRA A TOPE PRESISO, EH
* PUTA BASURA DE API
* status = RegEnumValueW(key, * status = RegEnumValueW(key,
* i, * i,
* valName, * valName,
@ -318,15 +312,14 @@ uint64_t estimandoFreq(){
int main(int argc, char** argv){ int main(int argc, char** argv){
//AMD Momento //AMD Momento
char* opiniones = AMDTest(); char* opiniones = AMDMeCagoEnTusPutosMuertos();
bool w11 = AMDGMET(); bool w11 = AMDJoderMET();
for (int i = 0; i < 3; i++) { for (int i = 0; i < 3; i++) {
uint64_t isItActually32GHz = estimandoFreq(); uint64_t isItActually32GHz = estimandoFreq();
log_debugcpp("ayo we found " << isItActually32GHz << " flash knuckle"); log_debugcpp("ayo we found " << isItActually32GHz << " flash knuckle");
} }
int64_t juas = getFreqFromReg(); int64_t juas = getFreqFromReg();
log_debugcpp("satr " << checksatr()); log_debugcpp("JODER " << juas);
log_debugcpp("Invariant " << checkInvariantTSC());
//iwintewel //iwintewel
//Cordura //Cordura

View file

@ -5,8 +5,7 @@
#define _MT #define _MT
#define _DLL #define _DLL
#include <Windows.h> #include <Windows.h>
#include <fileapi.h> #include <libloaderapi.h>
//#include <libloaderapi.h>
#endif #endif
#include "../debug.h" #include "../debug.h"
@ -15,31 +14,11 @@
using namespace tmr; using namespace tmr;
#ifdef _WIN64 #ifdef _WIN64
static inline int64_t getQPCTicks() {
LARGE_INTEGER ticks;
if (!QueryPerformanceCounter(&ticks))
{
return 0;
}
return ticks.QuadPart;
}
static inline int64_t getQPCFrequency() {
LARGE_INTEGER ticks;
if (!QueryPerformanceFrequency(&ticks))
{
return 0;
}
return ticks.QuadPart;
}
int main(int argc, char** argv){ int main(int argc, char** argv){
//HMODULE dell; HMODULE dell;
//DWORD fracaso; DWORD fracaso;
//DllImport TSCTimer* timer; //DllImport TSCTimer* timer;
uint64_t sleep = 1; int sleep = 1000;
uint64_t checks = 0;
/* /*
* dell = LoadLibraryExW(TEXT("libtmrtsc.dll"), NULL, NULL); * dell = LoadLibraryExW(TEXT("libtmrtsc.dll"), NULL, NULL);
@ -52,42 +31,13 @@ int main(int argc, char** argv){
timer = TSCTimer::getTimer(); timer = TSCTimer::getTimer();
if(timer == nullptr) if(timer == nullptr)
return -2; return -2;
uint64_t wfr = getQPCFrequency(); uint64_t t1 = timer->getTimeStamp();
int64_t fr = 3193999000;//timer->getBaseFrequency(); Sleep(sleep);
uint64_t t2 = timer->getTimeStamp();
uint64_t fr = timer->getBaseFrequency();
uint64_t wt1 = getQPCTicks(); std::cout << "Siestecita de: " << sleep << " ms" << std::endl;
int64_t t1 = timer->getTimeStamp(); std::cout << "Windows Momento: \nt1: " << t1 << " t2: " << t2 << " fr: " << fr << std::endl;
int64_t t2 = timer->getTimeStamp();
while ((t2 - t1) < (sleep * fr)) {
t2 = timer->getTimeStamp();
checks++;
}
//uint64_t fr = timer->getBaseFrequency();
uint64_t wt2 = getQPCTicks();
std::cout << "Sleep: " << sleep << "s\n-----------------\nTest 1: TSCTimer within QPC\n" << std::endl;
std::cout << "QPC Momento: \n t1: " << wt1 << " t2: " << wt2 << " fr: " << wfr << std::endl;
std::cout << " restita: " << wt2-wt1 << std::endl;
std::cout << "TSCTimer Momento: \n t1: " << t1 << " t2: " << t2 << " fr: " << fr << std::endl;
std::cout << "restita: " << t2-t1 << std::endl; std::cout << "restita: " << t2-t1 << std::endl;
std::cout << " checks: " << checks << "\n-----------------\nTest 2: QPC within TSCTimer\n"<< std::endl;
checks = 0;
t1 = timer->getTimeStamp();
wt1 = getQPCTicks();
wt2 = getQPCTicks();
while ((wt2 - wt1) < (sleep * wfr)) {
wt2 = getQPCTicks();
checks++;
}
//uint64_t fr = timer->getBaseFrequency();
t2 = timer->getTimeStamp();
std::cout << "QPC Momento: \n t1: " << wt1 << " t2: " << wt2 << " fr: " << wfr << std::endl;
std::cout << " restita: " << wt2-wt1 << std::endl;
std::cout << "TSCTimer Momento: \n t1: " << t1 << " t2: " << t2 << " fr: " << fr << std::endl;
std::cout << " restita: " << t2-t1 << std::endl;
std::cout << " checks: " << checks << std::endl;
return 0; return 0;
} }

View file

@ -47,6 +47,7 @@ namespace tmr {
int64_t TSCTimer::intelRetrieveART(){ int64_t TSCTimer::intelRetrieveART(){
//TODO: Find a valid Intel CPU to debug ART route //TODO: Find a valid Intel CPU to debug ART route
//if (freq == nullptr) return -
uint64_t raxde, rbxnum, rcxhz; uint64_t raxde, rbxnum, rcxhz;
asm volatile ( ".intel_syntax noprefix\t\n" \ asm volatile ( ".intel_syntax noprefix\t\n" \