프로그램 사용/gcc2021. 5. 7. 17:30

%p로 출력하니 0일 경우 (nil)로 출력되네?

 

[링크 : https://stackoverflow.com/questions/4744650/nil-pointer-in-c-c]

'프로그램 사용 > gcc' 카테고리의 다른 글

gcc vectorized loop  (0) 2021.06.30
gcc unsigned to signed cast  (0) 2021.06.22
gcc -D 옵션 인자를 printf로 출력하기  (0) 2021.04.08
Auto-vectorization in GCC  (0) 2021.03.25
gcc -march 옵션  (0) 2021.01.24
Posted by 구차니
프로그램 사용/gcc2021. 4. 8. 12:02

와.. 먼가 쓸데없는 뻘짓 ㅋㅋㅋ

 

makefile 에서 \" \" 로 감싸주니 의외로 간단하게 해결

#CROSS_PREFIX	= arm-buildroot-linux-gnueabihf
CFLAGS			= $(INCLUDEDIRS) -o -W -Wall -O2 -DCROSS_PREFIX=\"$(CROSS_PREFIX)\"

 

테스트 코드

void main()
{
    printf("%s\n", CROSS_PREFIX);
}

 

'프로그램 사용 > gcc' 카테고리의 다른 글

gcc unsigned to signed cast  (0) 2021.06.22
gcc %p (nil)  (0) 2021.05.07
Auto-vectorization in GCC  (0) 2021.03.25
gcc -march 옵션  (0) 2021.01.24
g++ 은 정적 빌드가 안되나?  (0) 2021.01.19
Posted by 구차니
프로그램 사용/gcc2021. 3. 25. 16:53

어떤게 변환되는지도 확인이 가능한 듯.

-ftree-vectorizer-verbose=[n] controls vectorization reports, with n ranging from 0 (no information reported) to 6 (all information reported).

 

25가지 예가 있는데 for a = b + c 같은건 된다고 한다.

Example 12: Induction:
Example 13: Outer-loop:
Example 14: Double reduction:
Example 15: Condition in nested loop:
Example 16: Load permutation in loop-aware SLP:
Example 17: Basic block SLP:
Example 18: Simple reduction in SLP:
Example 19: Reduction chain in SLP:
Example 20: Basic block SLP with multiple types, loads with different offsets, misaligned load, and not-affine Example 21: Backward access:
Example 22: Alignment hints:
Example 23: Widening shift:
Example 24: Condition with mixed types:
Example 25: Loop with bool:

[링크 : https://gcc.gnu.org/projects/tree-ssa/vectorization.html#using]

'프로그램 사용 > gcc' 카테고리의 다른 글

gcc %p (nil)  (0) 2021.05.07
gcc -D 옵션 인자를 printf로 출력하기  (0) 2021.04.08
gcc -march 옵션  (0) 2021.01.24
g++ 은 정적 빌드가 안되나?  (0) 2021.01.19
gcc offloading support  (0) 2020.11.24
Posted by 구차니
프로그램 사용/gcc2021. 1. 24. 11:24

오늘도 어김없이(?) 노인학대 옵션 찾는중

3.19.59 x86 Options
These ‘-m’ options are defined for the x86 family of computers.

-march=cpu-type
‘sandybridge’
Intel Sandy Bridge CPU with 64-bit extensions, MMX, SSE, SSE2, SSE3, SSSE3, SSE4.1, SSE4.2, POPCNT, AVX, AES and PCLMUL instruction set support.

[링크 : https://gcc.gnu.org/onlinedocs/gcc/x86-Options.html]

 

+

그래도 tensorflow 빌드 해서 실행하는데 속도에 유의미한 영향을 주진 않네

이런 라즈베리 파이 만도 못한 내 노트북 ㅠㅠㅠㅠ

(라즈베리 4코어 + neon 가속시  170ms 정도, i5-2520m 에서 1300ms ㅠㅠ)

Posted by 구차니
프로그램 사용/gcc2021. 1. 19. 11:00

 

tensorflow lite 빌드해서 static libaray 로 libtensorflow-lite.a는 얻어냈는데

얘를 링크해서 빌드하니 dynamic link가 된다.

 

궁금해서 hello.cpp 이런거 하나 구해서 g++로 빌드하니

무조건 끌어가는 것 같긴한데

$ cat hello.cpp
// hello.cpp file
#include <iostream>
int main()
{
    std::cout << "Hello Geek\n";
    return 0;
}

$ g++ hello.cpp
$ ldd a.out
        linux-vdso.so.1 (0x7efa4000)
        /usr/lib/arm-linux-gnueabihf/libarmmem-${PLATFORM}.so => /usr/lib/arm-linux-gnueabihf/libarmmem-v7l.so (0x76f7e000)
        libstdc++.so.6 => /usr/lib/arm-linux-gnueabihf/libstdc++.so.6 (0x76e19000)
        libm.so.6 => /lib/arm-linux-gnueabihf/libm.so.6 (0x76d97000)
        libgcc_s.so.1 => /lib/arm-linux-gnueabihf/libgcc_s.so.1 (0x76d6a000)
        libc.so.6 => /lib/arm-linux-gnueabihf/libc.so.6 (0x76c1c000)
        /lib/ld-linux-armhf.so.3 (0x76f93000)

 

혹시나 해서 g++ -static 옵션을 주니 되긴 되네..

$ g++ hello.cpp -o b.out -static
$ ldd b.out
        not a dynamic executable

'프로그램 사용 > gcc' 카테고리의 다른 글

Auto-vectorization in GCC  (0) 2021.03.25
gcc -march 옵션  (0) 2021.01.24
gcc offloading support  (0) 2020.11.24
gcc 특정 영역만 최적화 하지 않게 하기  (0) 2020.10.21
gcc의 linker 옵션 은 가장 끝에  (0) 2019.06.21
Posted by 구차니
프로그램 사용/gcc2020. 11. 24. 11:12

intel xeon Phi (KNL) 이나 Nvidia PTX 그리고 AMD HSAIL을 지원하는 predictive 라고 해도 먼 소리인지 모르겠다.

 

 

[링크 : https://gcc.gnu.org/wiki/Offloading]

[링크 : https://gcc.gnu.org/wiki/nvptx]

[링크 : https://gcc.gnu.org/wiki/OpenACC]

 

[링크 : https://repository.kisti.re.kr/bitstream/10580/6542/1/2014-147%20Slurm%20관리자%20이용자%20가이드.pdf]

'프로그램 사용 > gcc' 카테고리의 다른 글

gcc -march 옵션  (0) 2021.01.24
g++ 은 정적 빌드가 안되나?  (0) 2021.01.19
gcc 특정 영역만 최적화 하지 않게 하기  (0) 2020.10.21
gcc의 linker 옵션 은 가장 끝에  (0) 2019.06.21
c large file support  (0) 2019.06.21
Posted by 구차니
프로그램 사용/gcc2020. 10. 21. 12:47

gcc 4.4 이후 버전 사용가능

#pragma GCC push_options
#pragma GCC optimize ("O0")

your code

#pragma GCC pop_options

 

void __attribute__((optimize("O0"))) foo(unsigned char data) {
    // unmodifiable compiler code
}

[링크 : https://stackoverflow.com/questions/2219829/how-to-prevent-gcc-optimizing-some-statements-in-c]

'프로그램 사용 > gcc' 카테고리의 다른 글

g++ 은 정적 빌드가 안되나?  (0) 2021.01.19
gcc offloading support  (0) 2020.11.24
gcc의 linker 옵션 은 가장 끝에  (0) 2019.06.21
c large file support  (0) 2019.06.21
gcc5 atoi / stoi  (0) 2019.06.14
Posted by 구차니
프로그램 사용/gcc2019. 6. 21. 17:40

예전글에서 누락된 부분인데..

-l로 링커에 넘겨서 붙일 녀석들은 왜인지 모르겠지만 가장 마지막에 옵션을 주어야 한다.

 

아래처럼 파일명 이후에 -l을 넣어주면 문제없이 되는데

$ gcc -I/usr/include/libxml2 reader2.c  -lxml2 

 

-l 이후에 파일명을 넣으면 해당 파일을 찾을수 없다고 나온다.

(그냥 테스트 해보면 -lxml2를 넣지 않은것과 동일하다)

$ gcc -I/usr/include/libxml2 -lxml2 reader2.c
/tmp/ccUmEsNl.o: In function `processNode':
reader2.c:(.text+0x19): undefined reference to `xmlTextReaderConstName'
reader2.c:(.text+0x3b): undefined reference to `xmlTextReaderConstValue'
reader2.c:(.text+0x4b): undefined reference to `xmlTextReaderHasValue'
reader2.c:(.text+0x5a): undefined reference to `xmlTextReaderIsEmptyElement'
reader2.c:(.text+0x69): undefined reference to `xmlTextReaderNodeType'
reader2.c:(.text+0x77): undefined reference to `xmlTextReaderDepth'
reader2.c:(.text+0xb8): undefined reference to `xmlStrlen'
/tmp/ccUmEsNl.o: In function `streamFile':
reader2.c:(.text+0x11d): undefined reference to `xmlReaderForFile'
reader2.c:(.text+0x138): undefined reference to `xmlTextReaderRead'
reader2.c:(.text+0x155): undefined reference to `xmlTextReaderRead'
reader2.c:(.text+0x16a): undefined reference to `xmlTextReaderIsValid'
reader2.c:(.text+0x19a): undefined reference to `xmlFreeTextReader'
/tmp/ccUmEsNl.o: In function `main':
reader2.c:(.text+0x209): undefined reference to `xmlCheckVersion'
reader2.c:(.text+0x221): undefined reference to `xmlCleanupParser'
reader2.c:(.text+0x226): undefined reference to `xmlMemoryDump'
collect2: error: ld returned 1 exit status

 

머지?

foo.o -lz bar.o일 경우

foo.o는 libz가 로드 되지만, bar.o 에서는 libz가 로드되지 않는다?

-llibrary
-l library
Search the library named library when linking. (The second alternative with the library as a separate argument is only for POSIX compliance and is not recommended.)
It makes a difference where in the command you write this option; the linker searches and processes libraries and object files in the order they are specified. Thus, foo.o -lz bar.o searches library z after file foo.o but before bar.o. If bar.o refers to functions in z, those functions may not be loaded.

The linker searches a standard list of directories for the library, which is actually a file named liblibrary.a. The linker then uses this file as if it had been specified precisely by name.

The directories searched include several standard system directories plus any that you specify with -L.

Normally the files found this way are library files---archive files whose members are object files. The linker handles an archive file by scanning through it for members which define symbols that have so far been referenced but not defined. But if the file that is found is an ordinary object file, it is linked in the usual fashion. The only difference between using an -l option and specifying a file name is that -l surrounds library with lib and .a and searches several directories.

[링크 : https://linux.die.net/man/1/gcc]

'프로그램 사용 > gcc' 카테고리의 다른 글

gcc offloading support  (0) 2020.11.24
gcc 특정 영역만 최적화 하지 않게 하기  (0) 2020.10.21
c large file support  (0) 2019.06.21
gcc5 atoi / stoi  (0) 2019.06.14
gcc variadic macro  (0) 2017.06.20
Posted by 구차니
프로그램 사용/gcc2019. 6. 21. 17:02

아래의 선언을 해주면 된다는데.. 모르겠다?

 

-D_LARGE_FILE_SOURCE=1

[링크 : https://stackoverflow.com/questions/14533836/large-file-support-not-working-in-c-programming]

'프로그램 사용 > gcc' 카테고리의 다른 글

gcc 특정 영역만 최적화 하지 않게 하기  (0) 2020.10.21
gcc의 linker 옵션 은 가장 끝에  (0) 2019.06.21
gcc5 atoi / stoi  (0) 2019.06.14
gcc variadic macro  (0) 2017.06.20
문자열에 escape 로 특수문자 넣기  (0) 2017.06.19
Posted by 구차니
프로그램 사용/gcc2019. 6. 14. 15:28

????

'프로그램 사용 > gcc' 카테고리의 다른 글

gcc의 linker 옵션 은 가장 끝에  (0) 2019.06.21
c large file support  (0) 2019.06.21
gcc variadic macro  (0) 2017.06.20
문자열에 escape 로 특수문자 넣기  (0) 2017.06.19
gcc cpp type (유니코드 문자열)  (0) 2017.04.04
Posted by 구차니