Hi Chris,

First, you will need to have some configure stuff to detect nvcc and use it inside your Makefile. UTK may have some examples to show here.

For the C/C++ API, you need to add 'extern "C"' statements around the interfaces you want to export in C so that you can use them inside Open MPI.

You can look at the NCCL code for an example :
https://github.com/NVIDIA/nccl/blob/master/src/nccl.h#L19-L21
Note the ifdefs in case this .h is included from in C code.

In the .cu, the 'extern "C"' is burried into defines :
https://github.com/NVIDIA/nccl/blob/master/src/core.h#L149-L150

So an example would be :
myapi.h :
#ifdef __cplusplus
extern "C" {
#endif
void myfunc(...);
#ifdef __cplusplus
}
#endif
lib.cu :
extern "C" __attribute__ ((visibility("default"))) void myfunc(...) { ... }

Sylvain

On 01/27/2017 09:00 AM, Chris Ward wrote:
It looks like the mailing system deleted the attachment, so here it is inline
#
# Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
#     University Research and Technology
#     Corporation.  All rights reserved.
# Copyright (c) 2004-2005 The University of Tennessee and The University
#     of Tennessee Research Foundation.  All rights
#     reserved.
# Copyright (c) 2004-2009 High Performance Computing Center Stuttgart,
#     University of Stuttgart.  All rights reserved.
# Copyright (c) 2004-2005 The Regents of the University of California.
#     All rights reserved.
# Copyright (c) 2010      Cisco Systems, Inc.  All rights reserved.
# Copyright (c) 2012 Sandia National Laboratories. All rights reserved.
# Copyright (c) 2013      Los Alamos National Security, LLC. All rights
#     reserved.
# Copyright (c) 2016      IBM Corporation.  All rights reserved.
# $COPYRIGHT$
#
# Additional copyrights may follow
#
# $HEADER$
#

AM_CPPFLAGS = $(coll_ibm_CPPFLAGS)

sources = \
       coll_ibm.h \
       coll_ibm_component.c \
       coll_ibm_module.c \
       coll_ibm_allgather.c \
       coll_ibm_allgatherv.c \
       coll_ibm_allreduce.c \
       coll_ibm_alltoall.c \
       coll_ibm_alltoallv.c \
       coll_ibm_barrier.c \
       coll_ibm_bcast.c \
       coll_ibm_exscan.c \
       coll_ibm_gather.c \
       coll_ibm_gatherv.c \
       coll_ibm_reduce.c \
       coll_ibm_reduce_scatter.c \
       coll_ibm_reduce_scatter_block.c \
       coll_ibm_scan.c \
       coll_ibm_scatter.c \
       coll_ibm_scatterv.c \
       comm_gpu.cu \
       allreduce_overlap.cc

SUFFIXES = .cu
#
#comm_gpu.lo: comm_gpu.cu
# /usr/local/cuda/bin/nvcc -gencode arch=compute_60,code=sm_60 -lcuda -O3 --compiler-options "-O2 -fopenmp -mcpu=power8 -fPIC" -c comm_gpu.cu
#        mv comm_gpu.o comm_gpu.lo

%.lo : %.cu
/usr/local/cuda/bin/nvcc -gencode arch=compute_60,code=sm_60 -lcuda -O3 --compiler-options "-O2 -fopenmp -mcpu=power8 -fPIC" -c $<
       mv $*.o .libs/
       touch $*.lo


# Make the output library in this directory, and name it either
# mca_<type>_<name>.la (for DSO builds) or libmca_<type>_<name>.la
# (for static builds).

if MCA_BUILD_ompi_coll_ibm_DSO
component_noinst =
component_install = mca_coll_ibm.la
else
component_noinst = libmca_coll_ibm.la
component_install =
endif

mcacomponentdir = $(ompilibdir)
mcacomponent_LTLIBRARIES = $(component_install)
mca_coll_ibm_la_SOURCES = $(sources)
if WANT_COLL_IBM_WITH_PAMI
mca_coll_ibm_la_LIBADD = $(coll_ibm_LIBS) \
 $(OMPI_TOP_BUILDDIR)/ompi/mca/common/pami/libmca_common_pami.la
else
mca_coll_ibm_la_LIBADD = $(coll_ibm_LIBS)
endif
mca_coll_ibm_la_LDFLAGS = -module -avoid-version $(coll_ibm_LDFLAGS)

noinst_LTLIBRARIES = $(component_noinst)
libmca_coll_ibm_la_SOURCES =$(sources)
libmca_coll_ibm_la_LIBADD = $(coll_ibm_LIBS)
libmca_coll_ibm_la_LDFLAGS = -module -avoid-version $(coll_ibm_LDFLAGS)

*T J (Chris) Ward, IBM Research.
Scalable Data-Centric Computing - Active Storage Fabrics - IBM System BlueGene
IBM United Kingdom Ltd., Hursley Park, Winchester, Hants, SO21 2JN
011-44-1962-818679
LinkedIn **_https://www.linkedin.com/profile/view?id=60628729_**
ResearchGate **_https://www.researchgate.net/profile/T_Ward2_**
**_
_**_IBM System BlueGene Research_* <http://www.research.ibm.com/bluegene/>***_ _**_IBM System BlueGene Marketing_* <http://www-03.ibm.com/systems/deepcomputing/bluegene/>*
**_
_**_IBM Resources for Global Servants_* <http://hurgsa.ibm.com/%7Etjcw/Compete/>***_ _**_IBM Branded Products_* <http://www.ibm.com/shop>***_IBM Branded Swag_* <http://ibmlogogear.com/default.aspx>**
<http://www.ibm.com/developerworks/linux/library/l-bluegene/index.html>


UNIX in the Cloud - Find A Place Where There's Room To Grow, with the original Open Standard. _Free Trial Here Today_ <http://sdf.lonestar.org/index.cgi?telnet> New Lamps For Old - _Diskless Remote Boot Linux_ <http://drbl.sourceforge.net/>from _National Center for High-Performance Computing, Taiwan_ <http://www.nchc.org.tw/en/>



Unless stated otherwise above:
IBM United Kingdom Limited - Registered in England and Wales with number 741598.
Registered office: PO Box 41, North Harbour, Portsmouth, Hampshire PO6 3AU


_______________________________________________
devel mailing list
devel@lists.open-mpi.org
https://rfd.newmexicoconsortium.org/mailman/listinfo/devel


-----------------------------------------------------------------------------------
This email message is for the sole use of the intended recipient(s) and may 
contain
confidential information.  Any unauthorized review, use, disclosure or 
distribution
is prohibited.  If you are not the intended recipient, please contact the 
sender by
reply email and destroy all copies of the original message.
-----------------------------------------------------------------------------------
_______________________________________________
devel mailing list
devel@lists.open-mpi.org
https://rfd.newmexicoconsortium.org/mailman/listinfo/devel

Reply via email to