TBB 의 concurrent container 들은 쓰레드 안전할 것 같은 이름을 가졌지만 method 마다 쓰레드 안전성이 다를 수 있다.

concurrent_unordered_map 은 insert, lookup, traversal 은 동시에 할 수 있으나 erase 는 쓰레드 안전하지 않다.

https://spec.oneapi.io/versions/latest/elements/oneTBB/source/containers/concurrent_unordered_map_cls.html

 

concurrent_unordered_map — oneAPI Specification 1.2-provisional-rev-1 documentation

 

spec.oneapi.io

http://egloos.zum.com/sweeper/v/3053901

 

[TBB] concurrent_unordered_map/multimap

Reference page : TBB reference manual - concurrent_unordered_map 1. concurrent_unordered_map 1) 주요 특징 삽입과 이터레이션은 쓰레드 세이프하다.concurrent_hash_map과 다르게 [] 오퍼레이터와 at 함수를 제공하며, 쓰레드

egloos.zum.com

안전하지 않은 method 들은 unsafe_erase 처럼 unsafe 가 붙어 있다. clear, swap 도 unsafe 하다.

https://spec.oneapi.io/versions/latest/elements/oneTBB/source/containers/concurrent_unordered_map_cls/unsafe_modifiers.html

 

Concurrently unsafe modifiers — oneAPI Specification 1.2-provisional-rev-1 documentation

 

spec.oneapi.io

insert, lookup, traversal 이 안전하다고 해서 그 값을 동시에 접근해서 읽고 쓰는게 안전하다는 것도 아니다. 만약에  std::shared_ptr 같은 구조체를 사용한다면 c++ 20 이전에는 atomic_store, atomic_load 를 사용하고 c++ 20 부터는 atomic_shared_ptr 을 사용해야 한다.

boost::shared_ptr 같은 구조체를 사용한다면 차라리 accessor 라는 것을 통해 동시 접근 제어를 할 수 있는 concurrent_hash_map 을 사용하는 것도 방법이다. accessor 는 rw, const_accessor 는 r 접근할 때 사용한다. accessor 는 atomic 구조체로 구현된 spin_rw_mutex 를 이용해 bucket 접근을 제어한다.

https://spec.oneapi.io/versions/latest/elements/oneTBB/source/containers/concurrent_hash_map_cls.html

 

concurrent_hash_map — oneAPI Specification 1.2-provisional-rev-1 documentation

 

spec.oneapi.io

https://oneapi-src.github.io/oneTBB/main/tbb_userguide/concurrent_hash_map.html

 

concurrent_hash_map — oneTBB documentation

 

oneapi-src.github.io

http://egloos.zum.com/sweeper/v/3053914

 

[TBB] concurrent_hash_map

Reference page: TBB reference manual - concurrent_hash_map 1. 주요 특징 count, find, insert, erase 동작은 쓰레드 세이프하다.count, find, insert, erase는 기존의 iterator를 무효화시킬 수 있다.count, find, insert, erase를 제외

egloos.zum.com

 

728x90

여러 저장소를 checkout 받아놓고 한번에 업데이트 받을 때는 아래와 같이 svn up 을 사용하면 된다.

> svn up path_a path_b path_c

명령창으로 update 상태가 보이긴 하지만 merge 나 conflict 처리를 별도로 해야해 불편하다. TortoiseSVN 로 업데이트 한 것 처럼 사용하고 싶으면 TortoiseProc.exe 를 사용하면 된다.

> TortoiseProc.exe /command:update /path:path_a

여러 폴더는 * 문자로 구분해 주면 된다.

> TortoiseProc.exe /command:update /path:path_a*path_b*path_c
Since some of the commands can take a list of target paths (e.g. committing several specific files) the 
/path parameter can take several paths, separated by a * character.

출처 : https://tortoisesvn.net/docs/release/TortoiseSVN_en/tsvn-automation.html

 

Appendix D. Automating TortoiseSVN

:log Opens the log dialog. The /path specifies the file or folder for which the log should be shown. Additional options can be set: /startrev:xxx, /endrev:xxx, /limit:xxx limits the amount of fetched messages /strict enables the 'stop-on-copy' checkbox, /m

tortoisesvn.net

참고 : https://stackoverflow.com/questions/26294735/tortoisesvn-how-to-update-multiple-directory-in-a-single-window

 

TortoiseSVN: How to update multiple directory in a single window

I want to create a command file that will update my SVN. I have two different path. I have a code below that will update two unique directory. Is there a way to do it in a single line of code? @e...

stackoverflow.com

 

728x90
int d = 42;
int o = 052;
int x = 0x2a;
int X = 0X2A;
int b = 0b101010; // C++14

int 형에 대해 10진수, 8진수, 16진수 표기법은 알고 있었는데 64 비트 정수는 잘 안 쓰다 보니 접미사로 뭘 붙여야하는지 잊어버렸다.

unsigned long long l1 = 18446744073709550592ull; // C++11
unsigned long long l2 = 18'446'744'073'709'550'592llu; // C++14
unsigned long long l3 = 1844'6744'0737'0955'0592uLL; // C++14
unsigned long long l4 = 184467'440737'0'95505'92LLU; // C++14

64 비트 정수는 ll 을 붙이면 된다. unsigned 형의 경우 u 를 추가하면 된다.

참고 : https://en.cppreference.com/w/cpp/language/integer_literal

 

Integer literal - cppreference.com

Allows values of integer type to be used in expressions directly. [edit] Syntax An integer literal has the form decimal-literal integer-suffix(optional) (1) octal-literal integer-suffix(optional) (2) hex-literal integer-suffix(optional) (3) binary-literal

en.cppreference.com

 

728x90
CREATE TABLE foo ( bar INT(20) ZEROFILL );

mysql 에서 칼럼 선언에 INT(20), BIGINT(20) 같이 type 뒤에 숫자가 있길래 varchar(20) 와 같이 사이즈 의미인가 싶었다. 하지만 검색해보니 값의 범위에는 영향을 주지 않고 표시할 때 너비 힌트 정도로 사용된다고 한다. :(

https://stackoverflow.com/questions/3135804/types-in-mysql-bigint20-vs-int20

 

Types in MySQL: BigInt(20) vs Int(20)

I was wondering what the difference between BigInt, MediumInt, and Int are... it would seem obvious that they would allow for larger numbers; however, I can make an Int(20) or a BigInt(20) and that...

stackoverflow.com

 

728x90
# ps -aux
USER       PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
root         1  0.0  0.0    896   528 ?        Sl   21:18   0:00 /init
root        10  0.0  0.0    896    84 ?        Ss   21:18   0:00 /init
root        11  0.0  0.0    896    84 ?        R    21:18   0:00 /init
root        12  0.0  0.0  10036  4928 pts/0    Ss   21:18   0:00 -bash
root       145  0.0  0.0  10856  3404 pts/0    R+   21:21   0:00 ps -aux

ps 명령어에 실행경로도 같이 출력하는 방법을 찾지 못했다.

/proc# ls
1     buddyinfo  cpuinfo    execdomains  irq        kpagecgroup  meminfo  pagetypeinfo  stat         tty
10    bus        crypto     filesystems  kallsyms   kpagecount   misc     partitions    swaps        uptime
11    cgroups    devices    fs           kcore      kpageflags   modules  sched_debug   sys          version
12    cmdline    diskstats  interrupts   key-users  loadavg      mounts   schedstat     sysvipc      vmallocinfo
149   config.gz  dma        iomem        keys       locks        mtrr     self          thread-self  vmstat
acpi  consoles   driver     ioports      kmsg       mdstat       net      softirqs      timer_list   zoneinfo

/proc 경로에 PID 로 된 폴더들이 있다.

/proc# ls -al 12/exe
lrwxrwxrwx 1 root root 0 Aug 28 21:20 12/exe -> /usr/bin/bash

ls -al /proc/[PID]/exe 로 실행 경로를 확인할 수 있다.

ls -al /proc/[PID]/cmdline 으로 실행 명령어를 확인할 수 있다고 한다.

출처 : https://smilekimna.tistory.com/entry/%ED%94%84%EB%A1%9C%EC%84%B8%EC%8A%A4-%EC%8B%A4%ED%96%89%EA%B2%BD%EB%A1%9C-%EC%B0%BE%EA%B8%B0

728x90

svn 옵션 중에 Set file dates to the "last commit time" 이라는 옵션이 있다. svn update 를 받으면 파일 시간을 마지막 커밋 시간을 맞춰주는 옵션이다. 이 옵션을 사용하면 svn update 속도를 빠르게 해준다는 이야기가 있다.

예를 들어 A 가 12:49 에 ConsoleApplicationTest.cpp 를 commit 을 했고 B 가 그 뒤에 업데이트 받았다면 파일 시간이 12:49이 된다.

그런데 위 업데이트를 보면 B 가 12:51 에 빌드를 했다. 그리고 나서 업데이트로 수정 사항이 발생했는데 해당 파일의 파일 시간은 12:49 이다. 빌드 이전 파일인 관계로 수정 사항이 있었으나 VS 가 빌드를 하지 않는다. -_-

last commit time 옵션 사용할 때 주의하자.

https://stackoverflow.com/questions/2171939/how-can-i-keep-the-original-file-commit-timestamp-on-subversion

 

How can I keep the original file [commit] timestamp on Subversion?

I want to be sure that if I commit something in Subversion from one machine, and I checkout on another, I will get the same value for datetime and timestamp. Currently, I observed that the datetim...

stackoverflow.com

 

728x90

Visual Studio 2019 로 작업 중인데 incredibuild 없이 빌드하면 컴파일/링크 하느라 메시지 확인이나 문서 업데이트 같은 다른 작업을 진행하기 힘들었다.

Visual Studio  옵션 중에 최대 병렬 프로젝트 빌드 수를 코어 수보다 작게 조절해 봤지만 큰 차이를 느낄 수 없었다.

회사 동료분이 검색해서 찾으신 방법은 컴파일과 링크에 사용되는 cl.exe 와 link.exe 의 프로세스 우선순위를 낮추는 방법이었다.

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\cl.exe]
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\cl.exe\PerfOptions]
"CpuPriorityClass"=dword:00000005
"IoPriority"=dword:00000001

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\link.exe]
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\link.exe\PerfOptions]
"CpuPriorityClass"=dword:00000005
"IoPriority"=dword:00000001

레지스트리를 이용해 cl.exe 와 link.exe 의 cpu 우선순위를 below normal 로 바꾸는 방식이다.

참고 : https://developercommunity.visualstudio.com/t/limit-cpu-usage-of-visual-studio/436208

 

Limit CPU usage of Visual Studio during C++ build

<p>We have C++ solution with ~100 projects. When we build it with VS2017, the computer becomes virtually unusable. VS spawns ~64 cl.exe, and even mou...

developercommunity.visualstudio.com

Visual Studio 2022 version 17.3 에 수정되었다는데 뭐가 바뀐건지 모르겠다. @_@

728x90
가나

다라

윈도우즈 배치파일에서 echo 를 사용해 위와 같이 빈줄을 출력하고 싶을 때 

@echo off
echo 가나
echo.
echo 다라
pause

"echo." 을 사용하면 빈 줄을 출력해 준다.

@echo off
echo 가나
echo:
echo 다라
pause

"echo:" 도 같은 동작을 한다.

참고 :https://stackoverflow.com/questions/132799/how-can-i-echo-a-newline-in-a-batch-file

 

How can I echo a newline in a batch file?

How can you you insert a newline from your batch file output? I want to do something like: echo hello\nworld Which would output: hello world

stackoverflow.com

 

728x90

Visual Studio 로 같은 파일 내에 있는 코드를 참조할 일이 있을 때 창 > 분할 메뉴를 자주 사용한다.

Notepad++ 로 스크립트 파일 볼 때도 필요해서 찾아봤지만 메뉴에서 찾을 수가 없었다.

검색 해 보니 탭에서 '분할 창으로 복사'(clone to other view) 기능을 사용하면 됐다.

기본으로는 오른쪽에 창이 분할 보인다. 경계선 오른쪽 마우스 메뉴에서 오른쪽으로 회전을 선택하면 위-아래로 분할해서 볼 수 있다.

참고 : https://superuser.com/questions/332163/can-i-get-split-screen-in-notepad-like-emacs

 

Can I get split screen in Notepad++ like Emacs?

One of the good points with Emacs is that you can have split the screen so you get two or more views of the same file which allows you to browse around and have a clearer overview of the file. Are ...

superuser.com

 

728x90
do
{
	// do something
} while (false)

1번만 실행되는 코드를 저렇게 묶어놨길래 scope 때문에 저랬나 싶었다.

do
{
	if (A)
	{
		break;
	}
	if (B)
	{
		break;
	}
} while(false)

// do something finally

보니깐 goto 대신 scope 를 빠져 나가기 위해서 사용하는 스타일이었다.

#define DO_SOMETHINGS(X) \
	DO_FUNC_A(X); \
	DO_FUNC_B(X);

DO_SOMETHINGS(a); // DO_FUNC_A -> DO_FUNC_B

// if true, DO_FUNC_A -> DO_FUNC_B -> DO_FUNC_C
// if false, DO_FUNC_B -> DO_FUNC_C ????
if (IS_TRUE(a))
	DO_SOMETHINGS(a); 
DO_FUNC_C(a);

do...while(false) 를 사용하는 또 다른 용도로는 if  문 같은 곳에서 의도치 않은 흐름을 막을 수 있다. 위와 같은 경우 if 문에서 false 일 경우 의도치 않게 B -> C 가 호출된다.

#define DO_SOMETHINGS(X) \
	do \
	{ \
		DO_FUNC_A(X); \
		DO_FUNC_B(X); \
	} while(false);

위와 같은 상황을 피하고자 do while(false) 로 묶어서 선언한다.

참고 :

https://stackoverflow.com/questions/2314066/do-whilefalse

 

do {...} while(false)

I was looking at some code by an individual and noticed he seems to have a pattern in his functions: <return-type> function(<params>) { <initialization> do { <main code...

stackoverflow.com

https://still.tistory.com/79

 

goto 대신에 do { ... } while (false)를 사용한 에러처리

C/C++ 코딩을 하다보면 흔히 아래와 같은 에러처리 코드를 만나게 된다. ... if (!condition1)    goto cleanup; ... if (!condition2)    goto cleanup; ... if (!condition3)    goto cleanup; ... if (!c..

still.tistory.com

https://grandstayner.tistory.com/entry/C-do-while-false-%EB%A5%BC-%EC%82%AC%EC%9A%A9%ED%95%98%EB%8A%94-%EC%9D%B4%EC%9C%A0-12

 

C++ - do ~ while (false) 를 사용하는 이유 (1/2)

리눅스 커널 소스를 살펴보다가 헤더쪽의 매크로에서 “do { … } while(0)” 와 같은 것이 많이 쓰인 것을 보았다. 당연히 { … } 이 한번만 실행되고 끝나는 건데, 왜 이렇게 했을까 궁금해서 찾아

grandstayner.tistory.com

 

728x90

+ Recent posts