2020年3月16日 星期一

MTK mobile SoC summary

Sorted roughly by antutu scores
Type CPUS, GPU Note
Dimension 1000 A77 A55 G77 7nm
Dimension 1000L A77 A55 G77 7nm
Dimension 800 A76 A55 G57 7nm
G90T A76 A55 G76
G90 A76 A55 G76
P95 P90 A75 A55 PowerVR9446
G80 G70 P65 A75 A55 G52
X30 A73 A53 A35 PowerVR 7XTP-MT4 10nm
P70 P60 A73 A73 G72
P series below A53 with some GPU Not recommended

2020年2月16日 星期日

use ccache to accelerate compiling time in CMake

CMake > 3.4.0
define
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache
or add below in CMakeLists.txt
set(CMAKE_CXX_COMPILER_LAUNCHER ccache)
https://stackoverflow.com/a/37828605

make sure your ccache is latest to avoid bugs like

https://stackoverflow.com/a/47097937

2019年9月30日 星期一

clang plugin undefined reference

as https://patchwork.freedesktop.org/patch/219763/ suggestes, reorder the library including sequence

diff --git a/src/gallium/targets/opencl/Makefile.am b/src/gallium/targets/opencl/Makefile.am
index de68a93ad5..f0e1de7797 100644
--- a/src/gallium/targets/opencl/Makefile.am
+++ b/src/gallium/targets/opencl/Makefile.am
@@ -23,11 +23,10 @@  lib@OPENCL_LIBNAME@_la_LIBADD = \
  $(LIBELF_LIBS) \
  $(DLOPEN_LIBS) \
  -lclangCodeGen \
- -lclangFrontendTool \
  -lclangFrontend \
+ -lclangFrontendTool \
  -lclangDriver \
  -lclangSerialization \
- -lclangCodeGen \
  -lclangParse \
  -lclangSema \
  -lclangAnalysis \


2019年5月23日 星期四

llvm opt no effect?

in clang 5.0, it added a function call O0-optnone, which make your modification to llvm ir in passes not effective

compile you code with -Xclang -disable-O0-optnone then it will be effective again

2019年3月20日 星期三

prime nummber (C)

prime nummber
給你一個n,輸出第n個質數
// Comment

#include <stdio.h>
#include <stdint.h>

#define n 10000

uint64_t primes[n];

int main(void){

  int primesSize = 2;
  primes[0] = 2;
  primes[1] = 3; // notice n must >= 2
  for(uint64_t j = 4; j < UINTMAX_MAX; ++j){
    if(primesSize >= n)
      break;
    for(int k = 0; k < primesSize; ++k){
      if(j % primes[k] == 0)
        break;
      else if(primes[k]*primes[k] > j){
        primes[primesSize] = j;
        primesSize++;
        break;
      }
    }
  }
  printf("%lu\n", primes[n-1]);


  return 0;
}
也可以使用6n+-1法 簡易版是在第一層for迴圈加入 if(j%2==0||j%3==0)continue;

even odd sort (C)

給你一個n,接下來有n個整數,對他們排序使得
(1) 偶數在奇數前面
(2) 偶數遞減排序、奇數遞增排序
然後輸出這個數列
// Comment
#include <stdio.h>
#include <stdlib.h>

int lessthan(const void * p, const void * q){
  return *(int*)p - *(int*)q;
}

int greaterthan(const void * p, const void * q){
  return *(int*)q - *(int*)p;
}

void eosort(int * arr, int arrSize){
  int *a1 = (int*)malloc(sizeof(int)*arrSize);
  int *a2 = (int*)malloc(sizeof(int)*arrSize);
  int odd_index = 0;
  int even_index = 0;
  int i;
  for(i = 0; i < arrSize; ++i){
    if(arr[i] % 2){
      a1[odd_index++] = arr[i];
    }
    else
      a2[even_index++] = arr[i];
  }
  qsort(a1, odd_index, sizeof(int), lessthan);
  qsort(a2, even_index, sizeof(int), greaterthan);

  for(i = 0; i < even_index; ++i){
    arr[i] = a2[i];
  }
  for(i = 0; i < odd_index; ++i){
    arr[i + even_index] = a1[i];
  }
}


int main(void){
  int arr[] = {0, 9, 2, 7, 4, 5, 6, 3, 8, 1, 10};
  int arrSize = 11;
  eosort(arr, arrSize);
  int i;
  for(i = 0; i < arrSize; ++i){
    printf("%d ", arr[i]);
  }
  putchar('\n');
  return 0;
}

1004. Max Consecutive Ones III (C)

// Comment
int longestOnes(int* A, int ASize, int K) {
    int result = 0;
    int localmax = 0;
    int indexOfZero = 0;
    for(int i = 0; i < ASize; ++i){
        if(A[i] == 0)
            K--;
        localmax++;
        while(K<0){
            if(A[indexOfZero] == 0){
                K++;
            }
            indexOfZero++;
            
            localmax--;
        }
        result = localmax > result ? localmax : result;
        
    }
    return result;
}