Skip to content

Instantly share code, notes, and snippets.

View phaustin's full-sized avatar

Philip Austin phaustin

  • University of British Columbia
  • Vancouver, BC Canada
View GitHub Profile
@phaustin
phaustin / cmake.md
Created May 28, 2019 20:56
cmake find python
I am trying to embedd a python script with my C++ executable. I am using the instructions here: https://github.com/zooba/ogre3d-python-embed/blob/master/EmbeddingPython.md
I have pybind installed, I have used the embedded installation of python 3.7.3 and followed the dependency installation step such that if i use the python install adjactent to my executable, my deps load properly.
I believe i am having trouble getting pybind to actually use THIS installation of python. Can anyone point me toward anything i'm missing here? i would have assumed it would have looked adjacent to the executable but i know nothing.

Boris Staletic @bstaletic May 26 23:26
@faultfactory Configure your -DPYTHON_LIBRARY and -DPYTHON_INCLUDE_DIR.

Sergei Izmailov @sizmailov May 27 00:43
@faultfactory If you are using cmake<3.12 in addition you may want to ensure match of libraries to python interpreter by next snippet
@phaustin
phaustin / cmake.md
Created May 25, 2019 16:24
cmake add flags
Tom de Geus @tdegeus May 24 05:27
@tatatupi I do it like this:
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=native")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DXTENSOR_USE_XSIMD=ON")
Also I think that CMake in Release mode already uses -O3, but you can easily check

Taiguara Tupinambás @tatatupi
@phaustin
phaustin / perf.md
Created May 24, 2019 18:44
perf.md
Do you know a good reference to know about pref? I have no experience with that

Wolf Vollprecht @wolfv 11:42
just do perf record ./mybinary and perf report
and send me a screenshot and the C++ code
you can also run perf record python3 myscript
if you have a pythone extensio
it will show which C++ functions use the most CPU time
@phaustin
phaustin / xtensor_templates.md
Created May 23, 2019 23:02
xtensor_templates
 think this is the template type returned: xt::xarray_adaptor<xt::xbuffer_adaptor<double *, xt::no_ownership, std::allocator<double>>, xt::layout_type::row_major, std::vector<pybind11::ssize_t, std::allocator<pybind11::ssize_t>>, xt::xtensor_expression_tag>
I would prefer if it could just be xt:xarray. But I guess it might not be possible to turn a cstyle array into xt::xarray. I guess I have to carry around that type althrough out my code....

phmalek @phmalek 13:01
If you want to know the types only to write the appropriate function, use templates. I refere you to one of my previous issues. You can use templates for your function inputs:
  template <class T>
 int func2(const T& b)
 {
     //Do something with b
@phaustin
phaustin / xtensor_templates.md
Created May 23, 2019 23:02
xtensor_templates
 think this is the template type returned: xt::xarray_adaptor<xt::xbuffer_adaptor<double *, xt::no_ownership, std::allocator<double>>, xt::layout_type::row_major, std::vector<pybind11::ssize_t, std::allocator<pybind11::ssize_t>>, xt::xtensor_expression_tag>
I would prefer if it could just be xt:xarray. But I guess it might not be possible to turn a cstyle array into xt::xarray. I guess I have to carry around that type althrough out my code....

phmalek @phmalek 13:01
If you want to know the types only to write the appropriate function, use templates. I refere you to one of my previous issues. You can use templates for your function inputs:
  template <class T>
 int func2(const T& b)
 {
     //Do something with b
@phaustin
phaustin / trio_report.md
Last active May 22, 2019 19:12
trio_report.md
Hello there, I just disovered the existence of Trio today and I was wondering how to gather results from tasks ran concurrently.
I want to do something similar to what asyncio does here:
async def child(x):
    print(f"Child sleeping {x}")
    await asyncio.sleep(x)
    return 2*x

async def parent():
    tasks = [child(t) for t in range(3)]
@phaustin
phaustin / resource_report.py
Created May 22, 2019 19:06
jupyterhub resource report
```
global config:
https://github.com/pangeo-data/pangeo-cloud-federation/blob/eef3a575973f9789bcdb496b794e2334a88b4661/deployments/nasa/config/common.yaml#L59-L64
Here is a handy function to print some user-friendly information. But this is for the node(EC2) that the pod is on, rather than the resource limits identified in the JupyterHub config above. So in our case, the effective resources available to you are about 1/2 of the total since we have set resource limits with the intension of putting two user pods on every machine...
def tell_system_status():
# from https://www.programcreek.com/python/example/53878/psutil.disk_usage
import psutil
import platform
import datetime
@phaustin
phaustin / pinning_numpy.md
Last active May 21, 2019 16:04
pinning numpy
Hi all, I have a strange behavior in recipes regarding numpy version
I want to build a package that depends on Numpy, the recipe contain the following:
 requirements:
  build:
    - {{ compiler('cxx') }}
    - cmake
  host:
    - xtl >=0.6.2,<0.7
    - xtensor >=0.20.4,<0.21
@phaustin
phaustin / pangeo.md
Created April 17, 2019 01:41
pangeo talks

Julia Kent @jukent 14:27 @rabernat I am working on putting together a presentation on NCAR's role in Pangeo and in looking through the materials I see that you have produced many similarly templated presentations (such as this one https://speakerdeck.com/rabernat/cloud-native-climate-data-with-zarr-and-xarray) I was wondering if that template is available for use. I think it is really well designed.

Joe Hamman @jhamman 14:43 @jukent - I can send you the template. Also, see here. https://github.com/pangeo-data/pangeo-presentations/wiki https://www.dropbox.com/s/1c6pu3ul17037hq/pangeo_binder_agu_draft.key?dl=0

Julia Kent @jukent

@phaustin
phaustin / profile_trio.md
Created April 12, 2019 20:23
profiling trio

Nathaniel J. Smith @njsmith 19:36 whether you should expect profilers to be accurate in general is a complicated question :-) but many of them do work with trio

jtrakk @jtrakk 19:36 https://github.com/bdarnell/plop in particular

Nathaniel J. Smith @njsmith 19:37 I haven't tried that one but I'd say like, 90% likely it will work fine there are some weird issues around coroutines that can mess up stack sampling, but AFAIK trio has workarounds for them