Thursday, November 3, 2016

[작성예정] gdb, 코어덤프

코어덤프를 얻었을 때의 최대 이점은 문제가 발생했을 때의 상태를 보존할 수 있다는 점이다. 문제가 발생한 프로그램의 실행파일과 코어덤프가 있다면 당시 프로세스의 상태를 알 수 있다.
 - Debug hacks, 요시오카 히로타카, 2010.

Thursday, September 15, 2016

boost-python wrapping. accessing to numpy array example

This is a example for boost-python, especially about numpy array.
The codes are about CMakeLists.txt, hello.py, hello.cpp file.
 --------------------------------------------------------------------------
cmake_minimum_required(VERSION 2.8 FATAL_ERROR)
find_package(PythonLibs REQUIRED)
string(REGEX MATCH "([0-9])\\.*" output ${PYTHONLIBS_VERSION_STRING})
if(${output} EQUAL "2.")
 find_package(Boost COMPONENTS python)
else()
    find_package(Boost COMPONENTS python3)
endif()
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG ${CMAKE_SOURCE_DIR})
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE ${CMAKE_SOURCE_DIR})
file(GLOB lib_headers "src/*.h")
file(GLOB lib_src "src/*.cpp")
set(prjname hello)
add_library(${prjname} SHARED ${lib_src} ${lib_headers})
set_target_properties(${prjname} PROPERTIES DEBUG_POSTFIX "_d")
if(WIN32)
  set_target_properties(${prjname} PROPERTIES SUFFIX ".pyd")
endif(WIN32)
target_include_directories(${prjname} PUBLIC ${Boost_INCLUDE_DIRS} ${PYTHON_INCLUDE_DIRS})
target_link_libraries(${prjname} ${Boost_LIBRARIES} ${PYTHON_LIBRARIES})
--------------------------------------------------------------------------
 
if __debug__:
 import hello_d as hello
else:
 import hello
import numpy as np

hello.greet()
uv = np.array([[1.0, 2.0]])
print 'uv =', uv
hello.get_set_element(uv, 3.0)
print 'uv0 = ', uv

#include <boost/python.hpp>
#include <boost/python/numeric.hpp>
#include <boost/python/extract.hpp>
#include <boost/python/tuple.hpp>

#ifdef _DEBUG
#define PY_MODULE BOOST_PYTHON_MODULE(hello_d)
#else
#define PY_MODULE BOOST_PYTHON_MODULE(hello)
#endif

char const* greet(){
        return "hello\n";
}

void get_set_element(boost::python::numeric::array& y, double value){
        double d = boost::python::extract<double>(y[boost::python::make_tuple(0, 0)]);
        printf("array[0,0] = %f\n", d);
        y[boost::python::make_tuple(0, 0)] = value;
}

PY_MODULE{
        boost::python::numeric::array::set_module_and_type("numpy", "ndarray");
        boost::python::def("get_set_element", &get_set_element);
        boost::python::def("greet", greet);
}

Sunday, July 3, 2016

Parallel programming with python

Module multiprocessing vs pp (parallel python) :
http://stackoverflow.com/questions/5181949/using-the-multiprocessing-module-for-cluster-computing

multiprocessing looks like better, general, if multiple node doesn't necessary.

multiprocessing
https://docs.python.org/2/library/multiprocessing.html

List of the libraries :
https://wiki.python.org/moin/ParallelProcessing

example)
http://www.parallelpython.com/content/view/17/31
http://www.parallelpython.com/content/view/15/30/#QUICKSMP
http://www.parallelpython.com/content/view/15/30/#QUICKCLUSTERS
To launch ppserver,
$ python /usr/local/bin/ppserver.py -s mypassword

#myclient.py
import pp
server = pp.Server(ppservers=("127.0.0.1", secret='mypassword')

Monday, March 28, 2016

Wednesday, November 18, 2015

파이썬 빌드(컴파일)

https://docs.python.org/2/extending/building.html

A distutils package contains a driver script, setup.py. This is a plain Python file, which, in the most simple case, could look like this:
from distutils.core import setup, Extension

module1 = Extension('demo',
                    sources = ['demo.c'])

setup (name = 'PackageName',
       version = '1.0',
       description = 'This is a demo package',
       ext_modules = [module1])

With this setup.py, and a file demo.c, running
python setup.py build

will compile demo.c, and produce an extension module named demo in the build directory. Depending on the system, the module file will end up in a subdirectory build/lib.system, and may have a name like demo.so ordemo.pyd.

Tuesday, November 10, 2015

ray tracing survey

ray tracing vs casting :
http://permadi.com/1996/05/ray-casting-tutorial-table-of-contents/

ray tracing :
https://www.cs.unc.edu/~rademach/xroads-RT/RTarticle.html

c++ example :
http://www.cosinekitty.com/raytrace/chapter05_cpp_code.html

ray tacing, ray packet, SAH(Surface Area Heuristic) :
http://www.cs.cmu.edu/afs/cs/academic/class/15869-f11/www/lectures/14_raytracing.pdf

아직 조사중.