'Programming'에 해당되는 글 1834건

  1. 2012.12.06 lisp tutorial
  2. 2012.12.05 lisp - #' 와 '
  3. 2012.12.03 php ++,-- 연산자
  4. 2012.12.03 클로져
  5. 2012.11.30 php if/else/echo
  6. 2012.11.26 php 간단정리
  7. 2012.11.19 lisp는 리스트지 prefix 표기법이 아니다
  8. 2012.10.12 mmx, sse intrinsics from MSDN.NET
  9. 2012.10.09 sse / mmx 확장
  10. 2012.09.20 cuda shared memory의 결합법칙?
Programming/lisp2012. 12. 6. 18:58
lisp 강의자료나 예제를 찾다가 발견
이 내용을 lisp 처음공부할때 보았더라면 이해를 했을텐데....

[링크 : http://www2.cs.sfu.ca/CourseCentral/310/pwfong/Lisp/]
[링크 : http://www.cs.sfu.ca/CourseCentral/310/pwfong/Lisp/1/tutorial1.html]

'Programming > lisp' 카테고리의 다른 글

lisp vector  (0) 2012.12.14
lisp atom  (0) 2012.12.11
lisp - #' 와 '  (0) 2012.12.05
클로져  (0) 2012.12.03
lisp는 리스트지 prefix 표기법이 아니다  (0) 2012.11.19
Posted by 구차니
Programming/lisp2012. 12. 5. 23:18
'는 quote(인용)인데
함수적 언어인 lisp에서 함수를 쓰지 않고 list나 atom을 만드는데 사용한다.
> (quote a)
A
> 'a
A
> '(a)
(A) 
> (quote (a))
(A) 

>'(+ 1 2)
(+ 1 2)

위의 예제와 같이 (quote val)과 'val은 동일하며 atom을 나타낼때 사용된다.
atom으로 쓰려면 'val
list로 쓰려면 '(val)
로 사용하면 된다. 물론 함수역시 list의 atom으로서 인식이 되어질수 있다.



#'는 lisp 문서를 보다가 찾게 된 녀석인데
#' 는 (function val)과 같은 의미이고
함수 포인터라고 하기도 모호하고 아무튼.. 아직은 이해가 잘 안되는 녀석..
APPLY is also a Lisp primitive function.
APPLY takes a function and a list of objects as input. It invokes the specified function with those objects as its inputs.  The first argument to APPLY should be quoted with #’ rather than an ordinary quote; #’ is the proper way to quote functions supplied as inputs to other functions.  This will be explained in more detail in Chapter 7.
(apply #'+ '(2 3)) ⇒ 5
(apply #’equal '(12 17)) ⇒ nil 

The #’ (or ‘‘sharp quote’’) notation is the correct way to quote a function in Common Lisp.  If you want to see what the function CONS looks like in your implementation, try the following example in your Lisp:
> (setf fn #’cons)
#<Compiled-function CONS {6041410}>
> fn
#<Compiled-function CONS {6041410}>
> (type-of fn)
COMPILED-FUNCTION
> (funcall fn ’c ’d)
(C . D) 

> #'+
#<SYSTEM-FUNCTION +> 

> (function +)
#<SYSTEM-FUNCTION +> 

---2012.12.11

#는 벡터라고 한다.
[링크 : http://www.cs.cmu.edu/Groups/AI/html/cltl/clm/node30.html]

'Programming > lisp' 카테고리의 다른 글

lisp atom  (0) 2012.12.11
lisp tutorial  (0) 2012.12.06
클로져  (0) 2012.12.03
lisp는 리스트지 prefix 표기법이 아니다  (0) 2012.11.19
lisp 관련 책  (0) 2012.01.25
Posted by 구차니
Programming/php2012. 12. 3. 07:59
$--a 인가? --$a 인가? 고민을 허무하게 해결 ㅋㅋㅋ

Increment/decrement Operators
Example Name Effect
++$a Pre-increment Increments $a by one, then returns $a.
$a++ Post-increment Returns $a, then increments $a by one.
--$a Pre-decrement Decrements $a by one, then returns $a.
$a-- Post-decrement Returns $a, then decrements $a by one.

'Programming > php' 카테고리의 다른 글

php framework / 읽을꺼리  (0) 2014.04.09
php 메뉴얼  (0) 2014.03.28
php $_SERVER 변수  (0) 2013.07.07
index.php가 다운받아지는 문제점 -_-  (0) 2013.02.22
php 간단정리  (0) 2012.11.26
Posted by 구차니
Programming/lisp2012. 12. 3. 07:54
익명함수 , 람다 폼 이런걸로 불리는데
lisp에서 유래된건진 모르겠지만, 요즘 유행하는 신형 언어들은 거의 대부분 채택하고 있다.

[링크 : http://www.langdev.org/posts/38]
[링크 : http://www.ibm.com/developerworks/kr/library/j-jtp04247.html]

[링크 : http://bluesky.springnote.com/pages/2017150 ]
[링크 : http://php.net/manual/kr/functions.anonymous.php]

[링크 : http://en.wikipedia.org/wiki/Anonymous_function#C_lambda_expressions
[링크 : http://en.wikipedia.org/wiki/Closure_%28computer_science%29

[링크 : http://ko.wikipedia.org/wiki/함수형_프로그래밍]
[링크 : http://ko.wikipedia.org/wiki/람다_대수]

'Programming > lisp' 카테고리의 다른 글

lisp tutorial  (0) 2012.12.06
lisp - #' 와 '  (0) 2012.12.05
lisp는 리스트지 prefix 표기법이 아니다  (0) 2012.11.19
lisp 관련 책  (0) 2012.01.25
lisp 문법  (0) 2012.01.24
Posted by 구차니
Programming/web 관련2012. 11. 30. 20:21
if문은 c언어와 거의 같다.
if - else if - else를 지원하고
else if 대신 elseif 를 지원한다(띄워쓰기 안한게 아님!) 
 

echo는 printf와 유사한데
echo $a."<br>";
echo "$a<BR>";

위에 두개는 같은 표현이다.
c와 같이 "abc""def" 처럼 문자열을 붙이는건 되지 않고
'.' 을 통해서 붙이는 것은 허용된다. 
확실히 $a 식으로 변수인것만 표현하면 printf 처럼 뒤에다가 변수를 연결안해줘도 되니 편하긴 함. 
단, $를 출력용도로 쓰기 위해서는  " " 이 아닌 ' ' 로 해야함

예를들어 $a를 출력하고 싶다면
echo '$a';
라고 하면된다.

[링크 : http://php.net/manual/kr/function.echo.php]

'Programming > web 관련' 카테고리의 다른 글

wan 에서 mac address 얻기  (0) 2013.07.09
축약주소 만들기 서비스  (0) 2013.07.08
php-mobile-detect  (0) 2013.02.23
TD 태그 - Chrome 과 IE 차이?  (0) 2011.05.30
IE8 / Chrome으로 HTML 분석하기  (2) 2011.03.09
Posted by 구차니
Programming/php2012. 11. 26. 00:27
인터프리터 언어의 특징을 따르며
변수명에는 $를 접두로 붙여서 사용한다.
함수명에는 function 을 식별자로 사용함

<?
$val_name
echo $val_name

function func_name()
{
   return val;
}
?>

'Programming > php' 카테고리의 다른 글

php framework / 읽을꺼리  (0) 2014.04.09
php 메뉴얼  (0) 2014.03.28
php $_SERVER 변수  (0) 2013.07.07
index.php가 다운받아지는 문제점 -_-  (0) 2013.02.22
php ++,-- 연산자  (0) 2012.12.03
Posted by 구차니
Programming/lisp2012. 11. 19. 14:33
지하철에서 오가다가 lisp 문서를 보다보니
(+ 1 2 3)
6

이런 내용이 있어서 곰곰히 생각해보니
이 써글(!) lisp를 못 읽었던 이유가
전위 표기법으로 착각을 하고 있었던것 -_-


list를 기반으로 하기에 모든건 list이고 
+는 단지 처음에 오는 식별자 혹은 함수 이름으로서 '+' 라는 점
그렇기에 +와 - 를 합쳐서 쓰려면
괄호가 늘어 난다는 점 -_-

또한 값으로만 이루어진 리스트는
'(a b c) 식으로 함수 없이 값만으로 이루어진 것이라는 접두가 필요하다는 점
머.. 이게 이번에 깨달은 걸려나? 

'Programming > lisp' 카테고리의 다른 글

lisp - #' 와 '  (0) 2012.12.05
클로져  (0) 2012.12.03
lisp 관련 책  (0) 2012.01.25
lisp 문법  (0) 2012.01.24
slime / lispbox  (0) 2012.01.24
Posted by 구차니
Programming/mmx & simd2012. 10. 12. 14:29
함수들 뒤지다 보니 MSDN 문서의 함수와 GCC의 함수들이 동일한것 발견.
도움이 될 듯 하니 일단 복사복사~

[링크 : http://msdn.microsoft.com/en-us/library/y0dh78ez(v=vs.80).aspx]



아무튼 요즘 신형 CPU들이야 SSE2를 넘어서 SSE3에 AVX(샌디부터)까지 지원하니
부동소수점 안되는 MMX를 할 필요도 없고
정수가 안되는 SSE를 쓸 필요도 없고
SSE2 이상 쓰세요~ 라는 기분의 비교표


[링크 : http://msdn.microsoft.com/en-US/library/esaffkes(v=vs.80).aspx



[링크 : http://msdn.microsoft.com/en-US/library/y08s279d(v=vs.80).aspx] 함수 이름 규칙


명령어를 비교해도 딱히 이게 SSE다 MMX다 라고 잘라말하기는 힘들다.
접미(suffix)를 보고 대충 짐작은 가지만 그렇다고 해서 확실한건 아니니..
[링크 : http://msdn.microsoft.com/en-us/library/ccky3awe(v=vs.80).aspx ] MMX 명령어
[링크 : http://msdn.microsoft.com/en-us/library/t467de55(v=vs.80).aspx] SSE 명령어

'Programming > mmx & simd' 카테고리의 다른 글

sse / mmx 확장  (0) 2012.10.09
Posted by 구차니
Programming/mmx & simd2012. 10. 9. 11:08
openMP / CUDA 책을 보다보니 MMX 확장명령을 많이 쓰길래
어떤 컴파일러에서 어떤 변수 타입으로 지원하나 조사..

[링크 : http://stackoverflow.com/questions/661338/sse-sse2-and-sse3-for-gnu-c]
  [링크 : http://software.intel.com/sites/default/files/m/9/4/c/8/e/18072-347603.pdf
  [링크 : http://www.intel.com/content/www/us/en/processors/architectures-software-developer-manuals.html
[링크 : http://gcc.gnu.org/onlinedocs/gcc-4.0.4/gcc/i386-and-x86_002d64-Options.html]
[링크 : http://gcc.gnu.org/onlinedocs/gcc-3.1/gcc/X86-Built-in-Functions.html]
[링크 : http://www.cs.fsu.edu/~xyuan/cis4930-cda5125/lect4_simd_sse.pptx]

---
ubuntu 10.04 LTS gcc의 경우
/usr/lib/gcc/i486-linux-gnu/4.x/include 경로에 ?mmintrin.h 라는 파일명으로 헤더가 존재한다.
(/usr/lib/gcc/i486-linux-gnu/4.6/include 우분투 12.04 에서는 4.6으로 나옴)
gcc 컴파일시 --mmmx -msse 등의 옵션을 주어야 하는듯 하다.

변수명은 intel 문서에서 처럼 __m64 도 지원하지만
__v2si__
__v4hi__
__v8qi__
__v2sf__ 등의 변수명을 지원하기도 한다.

/* The Intel API is flexible enough that we must allow aliasing with other
   vector types, and their scalar components.  */
typedef int __m64 __attribute__ ((__vector_size__ (8), __may_alias__));

/* Internal data types for implementing the intrinsics.  */
typedef int __v2si __attribute__ ((__vector_size__ (8)));
typedef short __v4hi __attribute__ ((__vector_size__ (8)));
typedef char __v8qi __attribute__ ((__vector_size__ (8)));
typedef long long __v1di __attribute__ ((__vector_size__ (8)));
typedef float __v2sf __attribute__ ((__vector_size__ (8)));

---
$ cat temp.c
#include <stdio.h>
#include <mmintrin.h>

void main()
{
        __m64 m64val;
} 

$ gcc temp.c
In file included from temp.c:2:
/usr/lib/gcc/i486-linux-gnu/4.4.3/include/mmintrin.h:32:3: error: #error "MMX instruction set not enabled"
temp.c: In function ‘main’:
temp.c:6: error: ‘__m64’ undeclared (first use in this function)
temp.c:6: error: (Each undeclared identifier is reported only once
temp.c:6: error: for each function it appears in.)
temp.c:6: error: expected ‘;’ before ‘m64val’
 
$ gcc -mmmx temp.c 

'Programming > mmx & simd' 카테고리의 다른 글

mmx, sse intrinsics from MSDN.NET  (0) 2012.10.12
Posted by 구차니
Programming/openCL & CUDA2012. 9. 20. 21:58
CUDA 책을 읽다가 결합법칙에서 계속 막혔었는데..
생각을 해보니 "공유 메모리"는 일정 갯수의 쓰레드 끼리만 공용으로 사용한다라는 사실을 잊고 있었던것...
다르게 보면, 공유 메모리로 복사할때는 4byte(int)형으로만 복사하면
상위레벨에서 블럭으로 system memory에서 블럭단위로 전송하여
쓰레드 블럭에서 알아서 분배하는 스타일로 복사하는 것이다.

그런 이유로, 공유 메모리 예제에서는
for문으로 왕창 복사하는게 아니라 __shared__로 정의된 배열중 하나의 값만 복사를 해서 넣는것 -_-



다르게 말하면 성능 저하를 감수하고
공유 메모리를 사용하지 않는다면 굳이 결합법칙에 머리 아플 이유도 없다는게 되려나? 

---
2012.9.22
다시보니 공유 메모리로가 아니라
로컬 메모리에서 로딩하는 모든 연산에 대한 문제이다.
cuda의 특성상 로컬 메모리(오프칩/저속) 에서 읽어오때 블럭단위로 전송을 하기에
단순하게 로컬 메모리에서 읽어 로컬메모리에 쓸때에도
로컬 메모리에서 읽는 부분의 성능 저하를 최소화 하기 위해
결합법칙을 지켜주는 것이 좋다.
 

'Programming > openCL & CUDA' 카테고리의 다른 글

cuda deviceQuery on GTX650  (0) 2013.02.17
cuda 5.0  (0) 2013.02.16
cudaMalloc 시작 위치?  (0) 2012.07.11
cudemMemcpy()  (0) 2012.06.07
cuda 에서 device memory의 용량을 초과하는 malloc은 위험해!  (0) 2012.06.06
Posted by 구차니