맥북에서 openmp를 돌리기 위해서는 좀 귀찮은 과정이 필요하다. (Visual Studio의 경우 기본적으로 포함되어 있다.)

XCode7 에서는 OpenMP 지원을 하지않기 때문에  

우선 homebrew설치 진행

터미널에서 아래의 코드를 실행하면 된다. (http://wooriworld2006.tistory.com/308)


ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"




나머지 설치 과정은 아래의 스택오버플로우를 참조...

http://stackoverflow.com/questions/33668323/clang-omp-in-xcode-under-el-capitan


2. homebrew를 이용해 openMP 설치

>>brew install clang-omp


3. X code  프로젝트 생성

4. User defined setting 에 CC 항목 추가 한 후  /usr/local/bin/clang-omp 추가

5. Other C flags 항목에 -fopenmp 추가

6. Header Search Path에 /usr/local/include 추가

7. Enable Modules (C and Objective-C) 를 No로 변경하기

8. Build Phases 에서 Link Binary With Libraries 에 /usr/local/lib/libiomp5.dylib 추가

9. symbolic link 추가 (터미널에서 다음 실행)

sudo ln -s /usr/local/bin/clang-omp++ /usr/local/bin/clang++-omp

10. 소스코드에 omp.h 헤더 include

#include "libiomp/omp.h"


===================================================================================

XCode에서 릴리즈한 아이가 제대로 동작하지 않아 gcc++5 를 이용한 방법을 찾아냈다.

http://mathcancer.blogspot.kr/2016/01/PrepOSXForCoding-Homebrew.html


- gcc5 설치 시 make bootstrap 과정에서 꽤나 오랜 시간이 걸리므로 쫄지말자.







'C and C++' 카테고리의 다른 글

Fixed-point in C/C++  (0) 2016.04.05
main function arguments  (0) 2016.03.11
OpenMP  (0) 2016.03.09
C언어 최적화 기법  (0) 2016.02.05
걸음마  (0) 2015.12.08

1.

Visual Studio에서 OpenMP 프로그래밍을 한다면, 프로젝트 옵션에서 openMP 활성화를 해주는 것을 잊지 말자.ㅠ

프로젝트 속성> Configuration Properties> C/C++ > Language > Open MP Support "Yes (/openmp)"





2.

난수를 생성하는 부분은 병렬화를 고려한 랜덤함수를 쓰지 않는 한 병렬화하지 않도록 하자.



'C and C++' 카테고리의 다른 글

main function arguments  (0) 2016.03.11
OpenMP in Macbook  (0) 2016.03.10
C언어 최적화 기법  (0) 2016.02.05
걸음마  (0) 2015.12.08
Fixed point with C++  (0) 2015.12.08

Problem

SDSoC lab1 을 하다가 hardware implementation이 진행되지 않는 오류를 접함.

log를 찾아보니 HLS 쪽 문제인 것 같아서 Vivado HLS 랩을 실행해보니 역시나 오류!


Bug Log

Vivado HLS:

"line marker directive requires a positive integer argument"

등의 오류가 남.


SDSoC:

"Problem detected in Vivado HLS run"



앞에 앉은 친구는 잘 설치해서 쓰고 있어서 원인이 뭔가 싶어 몇 번이고 재설치를 했지만 문제는 해결되지 않음.

SDSoC의 경우, 아직 출시되지 않은 툴이라 해당 툴에 대한 포럼은 많이 활성화되어 있지 않은 상태라


Solutions

1. encoding problem? (Not worked)

https://forums.xilinx.com/t5/High-Level-Synthesis-HLS/Vivado-HLS-C-csynth-Error/td-p/437726


2. LLVM update? (Not worked)


3. OS issue

https://forums.xilinx.com/t5/High-Level-Synthesis-HLS/Having-trouble-with-quot-Run-C-simulation-quot/td-p/410609


이걸로 해결함!

SDSoC는 별도의 HLS 를 따로 사용하고 있으므로, 

해당 Vivado HLS의 경로를 찾아가서 수정해주면 됨.




코드 아카데미를 하나씩 따라하다가, 이제 점점 큰 프로그램들도 짜보자 싶어서 맥에다가 파이썬 개발 환경을 구축했다.

역시, 다루는 도구가 이뻐야 뭐든 시작하지.

그냥 그렇게 생각하기로 했다. (먼산)


우선, 평소에 궁금했던 sublimetext3 를 설치했고, 

생각보다 가벼운 텍스트 에디터였기에, 이것저것 검색해가며 플러그인들을 추가로 설치했다.


기왕 설치한 거 여기저기 잘 쓸 수 있는 듯 하니 잘 써봐야지 :)


1. sublimetext3에서 키보드 입출력을 사용하는 프로그램도 실행해 볼 수 있도록 하는 플러그인

http://pinkwink.kr/622


2. sidebar 색상 변경 방법

http://stackoverflow.com/questions/27931448/why-do-sublime-text-3-themes-not-affect-the-sidebar


3. package control 설명 및 anaconda

https://realpython.com/blog/python/setting-up-sublime-text-3-for-full-stack-python-development/


'Python' 카테고리의 다른 글

Python 연습 프로젝트 1  (0) 2020.11.28
Tkinter 를 이용한 시계  (0) 2017.06.27
import  (0) 2016.02.08
functions  (0) 2016.02.08
Pig Latin  (0) 2016.02.08

1. math library

# Ask Python to print sqrt(25) on line 

import math

print math.sqrt(25) 


2. sqrt 만 import 해오기 / 전부 import 해오기

# Import *just* the sqrt function from math on line 3!

from math import sort

from math import *


3. library import 해올 때는 되도록 import module 한 다음 module.function 해서 쓸 것. 함수명/변수명 중복되서 막 사용될 수 있음.

import math            # Imports the math module

everything = dir(math) # Sets everything to a list of things from math

print everything       # Prints 'em all!


4. python 에 기본적으로 내장되어있는 함수들 .upper(), .lower(), str(), len(), max(), min(), abs()

def biggest_number(*args):    #여러개의 인자를 넘기는 방법이 특이하다. 오오.

    print max(args)

    return max(args)

    

def smallest_number(*args):

    print min(args)

    return min(args)


def distance_from_zero(arg):

    print abs(arg)

    return abs(arg)



biggest_number(-10, -5, 5, 10)

smallest_number(-10, -5, 5, 10)

distance_from_zero(-10)


5. max()

# Set maximum to the max value of any set of numbers on line 3!


maximum = max(1, 19231, 2.5)


print maximum


6. min()

# Set minimum to the min value of any set of numbers on line 3!


minimum = min(4, -2 , 10, 123, -123.1)


print minimum


7. abs()


absolute = abs(-42)


print absolute


8. type()

# Print out the types of an integer, a float,

# and a string on separate lines below.


print type(42)

print type(-1.2)

print type('keol')


9. 

def shut_down(s):

    if s == "yes":

        return "Shutting down"

    elif s == "no":

        return "Shutdown aborted"

    else:

        return "Sorry"


10.

import math


print math.sqrt(13689)


11.

def distance_from_zero(arg):

    if type(arg) == int or type(arg) == float:

        return abs(arg)

    else:

        return "Nope"



'Python' 카테고리의 다른 글

Tkinter 를 이용한 시계  (0) 2017.06.27
Mac에서 Python 개발 환경 구축하기  (0) 2016.02.18
functions  (0) 2016.02.08
Pig Latin  (0) 2016.02.08
Conditional and control flow  (0) 2016.02.05

1. def 함수명(인자이름):   <- 콜론!

# Define your spam function starting on line 5. You

# can leave the code on line 11 alone for now--we'll

# explain it soon!


def spam():

    """printing eggs! in console"""

    print "Eggs!"



# Define the spam function above this line.

spam()


2. 함수 호출하기

def square(n):

    """Returns the square of a number."""

    squared = n**2

    print "%d squared is %d." % (n, squared)

    return squared

    

# Call the square function on line 9! Make sure to

# include the number 10 between the parentheses.


square(10)


3. 함수 인자 사용방법

def power(base, exponent):  # Add your parameters here!

    result = base**exponent

    print "%d to the power of %d is %d." % (base, exponent, result)


power(37,4)  # Add your arguments here!


4. 함수 안에서 함수 사용하기

def one_good_turn(n):

    return n + 1

    

def deserves_another(n):

    return one_good_turn(n) + 2


5. 함수 만들기 연습

def cube(number):

    return number**3


def by_three(number):

    if number%3 == 0:

        return cube(number)

    else :

        return False

        



'Python' 카테고리의 다른 글

Mac에서 Python 개발 환경 구축하기  (0) 2016.02.18
import  (0) 2016.02.08
Pig Latin  (0) 2016.02.08
Conditional and control flow  (0) 2016.02.05
datetime library  (0) 2016.02.04

1.

print 'Welcome to the Pig Latin Translator!'


# Start coding here!

original = raw_input("Enter a word:")


2.

print 'Welcome to the Pig Latin Translator!'


# Start coding here!

original = raw_input("Enter a word:")

if len(original) > 0:

    print original

else:

    print "empty"


3. isalpha() 캐릭터로만 되어있는지 아닌지 알아보는 함수

print 'Welcome to the Pig Latin Translator!'


# Start coding here!

original = raw_input("Enter a word:")

if len(original) > 0 and original.isalpha():

    print original

else:

    print "empty"


4. 

pyg = 'ay'


original = raw_input('Enter a word:')


if len(original) > 0 and original.isalpha():

    print original

    word = original.lower()

    first = word[0]

else:

    print 'empty'


5. 문자열 concatenation 은 + 로. 동적 할당 이런거 신경 안써줘도 되넹

pyg = 'ay'


original = raw_input('Enter a word:')


if len(original) > 0 and original.isalpha():

    print original

    word = original.lower()

    first = word[0]

    new_word = word + first + pyg

    print new_word

else:

    print 'empty'


6. 배열 부분 접근 가능! matlab이랑 비슷하네

pyg = 'ay'


original = raw_input('Enter a word:')


if len(original) > 0 and original.isalpha():

    print original

    word = original.lower()

    first = word[0]

    new_word = word + first + pyg

    new_word = new_word[1:len(new_word)]

    print new_word

else:

    print 'empty'

'Python' 카테고리의 다른 글

import  (0) 2016.02.08
functions  (0) 2016.02.08
Conditional and control flow  (0) 2016.02.05
datetime library  (0) 2016.02.04
string  (0) 2016.02.02

1. 조건문 연습, 그 return 값

# Assign True or False as appropriate on the lines below!


# 17 < 118 % 100

bool_one = (17 < 328)


# 100 == 33 * 3 + 1

bool_two = ( 100 == (2*50) )


# 19 <= 2**4

bool_three = (19 <= 19)


# -22 >= -18

bool_four = (-22 >= -18)


# 99 != 98 + 1

bool_five = ( 99 != (98 + 1) )

# 20 + -10 * 2 > 10 % 3 % 2

bool_one = (20 - 10) > 15


# (10 + 17)**2 == 3**6

bool_two = (10 + 17) == 3**16


# 1**2**3 <= -(-(-1))

bool_three = 1**2 <= -1


# 40 / 20 * 4 >= -4**2

bool_four = 40 * 4 >= -4


# 100**0.5 != 6 + 4

bool_five = 100 != 10**2

#대입 연산자 우선순위는 python에서도 많이 낮은 듯 하다.


2. boolean 연산

"""

     Boolean Operators

---------------------------

True and True is True

True and False is False

False and True is False

False and False is False


True or True is True

True or False is True

False or True is True

False or False is False


Not True is False

Not False is True


"""

bool_one = False and False


# -(-(-(-2))) == -2 and 4 >= 16**0.5

bool_two = -(-(-(-2))) == -2 and 4 >= 16**0.5


# 19 % 4 != 300 / 10 / 10 and False

bool_three = 19 % 4 != 300 / 10 / 10 and False


# -(1**2) < 2**0 and 10 % 10 <= 20 - 10 * 2

bool_four =  -(1**2) < 2**0 and 10 % 10 <= 20 - 10 * 2


# True and True

bool_five = True and True

# 2**3 == 108 % 100 or 'Cleese' == 'King Arthur'

bool_one = 2**3 == 108 % 100 or 'Cleese' == 'King Arthur'


# True or False

bool_two = True or False


# 100**0.5 >= 50 or False

bool_three = 100**0.5 >= 50 or False


# True or True

bool_four = True or True


# 1**100 == 100**1 or 3 * 2 * 1 != 3 + 2 + 1

bool_five = 1**100 == 100**1 or 3 * 2 * 1 != 3 + 2 + 1

# not True

bool_one = not True


# not 3**4 < 4**3

bool_two = not 3**4 < 4**3


# not 10 % 3 <= 10 % 2

bool_three = not 10 % 3 <= 10 % 2


# not 3**2 + 4**2 != 5**2

bool_four = not 3**2 + 4**2 != 5**2


# not not False

bool_five = not not False


# False or not True and True

bool_one = False or not True and True


# False and not True or True

bool_two = False and not True or True


# True and not (False or False)

bool_three = True and not (False or False)


# not not True or False and not True

bool_four = not not True or False and not True


# False or not (True and True)

bool_five = False or not (True and True)



3. if-else

response = 'Y'


answer = "Left"

if answer == "Left":

    print "This is the Verbal Abuse Room, you heap of parrot droppings!"

    

# Will the above print statement print to the console?

# Set response to 'Y' if you think so, and 'N' if you think not.



4.

def using_control_once():

    if True:

        return "Success #1"


def using_control_again():

    if 1>0:

        return "Success #2"


print using_control_once()

print using_control_again()


5. 

answer = "'Tis but a scratch!"


def black_knight():

    if answer == "'Tis but a scratch!":

        return True

    else:             

        return False       # Make sure this returns False


def french_soldier():

    if answer == "Go away, or I shall taunt you a second time!":

        return True

    else:             

        return   False     # Make sure this returns False


6. if elif else (c언어 case 구문처럼 콜론으로 )

def greater_less_equal_5(answer):

    if answer > 5:

        return 1

    elif answer <5:          

        return -1

    else:

        return 0

        

print greater_less_equal_5(4)

print greater_less_equal_5(5)

print greater_less_equal_5(6)


7. 

def the_flying_circus():

    if True or True:    # Start coding here!

        # Don't forget to indent

        # the code inside this block!

        return True

    elif 1<0:

        # Keep going here.

        # You'll want to add the else statement, too!

        return True

    else :

        return True


'Python' 카테고리의 다른 글

functions  (0) 2016.02.08
Pig Latin  (0) 2016.02.08
datetime library  (0) 2016.02.04
string  (0) 2016.02.02
python 걸음마 시작  (0) 2016.02.02

http://www.joinc.co.kr/modules/moniwiki/wiki.php/Site/C/Documents/COptimization


몇몇개는 지금은 해당되지 않는 것도 있지만, 

꽤나 설득력 있는 것들도 많은 것 같다.


기왕 시뮬레이터를 손대기로 한 것이니, 조금씩 더 개선해보자.

'C and C++' 카테고리의 다른 글

OpenMP in Macbook  (0) 2016.03.10
OpenMP  (0) 2016.03.09
걸음마  (0) 2015.12.08
Fixed point with C++  (0) 2015.12.08
C++ , 객체지향  (0) 2015.12.08

1. library 불러오기

from datetime import datetime


2. 현재시간

from datetime import datetime


now = datetime.now()

print now


3. 년/월/일

from datetime import datetime


now = datetime.now()

print now

print now.year

print now.month

print now.day


from datetime import datetime

now = datetime.now()


print '%s/%s/%s' % (now.month, now.day, now.year)


4. 시:분:초

from datetime import datetime

now = datetime.now()


print '%s:%s:%s' % (now.hour, now.minute, now.second)

3.4 는 print 문법이 완전 다르구나 print ('{}:{}:{}' .format(now.hour, now.minute, now.second))


5. datetime 관련 정리

from datetime import datetime

now = datetime.now()


print '%s/%s/%s %s:%s:%s' % (now.month, now.day, now.year, now.hour, now.minute, now.second)


'Python' 카테고리의 다른 글

functions  (0) 2016.02.08
Pig Latin  (0) 2016.02.08
Conditional and control flow  (0) 2016.02.05
string  (0) 2016.02.02
python 걸음마 시작  (0) 2016.02.02

+ Recent posts