singa-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From wang...@apache.org
Subject [12/12] incubator-singa git commit: Transfer code from nusinga repo to singa apache repo. New commuinication framework is implemented to unify the frameworks of existing distributed deep learning systems. Communication is now implmented using ZeroMQ. API
Date Sun, 03 May 2015 14:04:17 GMT
Transfer code from nusinga repo to singa apache repo.
New commuinication framework is implemented to unify the frameworks of existing distributed deep learning systems.
Communication is now implmented using ZeroMQ. APIs are general to replace the implementation using MPI.
Tested on single node using examples in example/ folder. Todo test with other cluster configurations (e.g., multiple nodes).


Project: http://git-wip-us.apache.org/repos/asf/incubator-singa/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-singa/commit/b2dc51d2
Tree: http://git-wip-us.apache.org/repos/asf/incubator-singa/tree/b2dc51d2
Diff: http://git-wip-us.apache.org/repos/asf/incubator-singa/diff/b2dc51d2

Branch: refs/heads/master
Commit: b2dc51d2364593611e06ded3aaeadab8274fae13
Parents: 95b1e6d
Author: wang wei <wangwei@comp.nus.edu.sg>
Authored: Sun May 3 21:57:08 2015 +0800
Committer: wang wei <wangwei@comp.nus.edu.sg>
Committed: Sun May 3 21:57:08 2015 +0800

----------------------------------------------------------------------
 .gitignore                                 |    28 +
 LICENSE.md                                 |   864 +
 Makefile                                   |    90 +
 README.md                                  |     4 +-
 examples/cifar10/cluster.conf              |     3 +
 examples/cifar10/hostfile                  |    20 +
 examples/cifar10/model.conf                |   219 +
 examples/cifar10/run.sh                    |    50 +
 examples/mnist/batch.sh                    |    41 +
 examples/mnist/cluster.conf                |     3 +
 examples/mnist/conv.conf                   |   175 +
 examples/mnist/hostfile                    |     8 +
 examples/mnist/mlp.conf                    |   223 +
 examples/mnist/run.sh                      |    40 +
 include/communication/msg.h                |   187 +
 include/communication/socket.h             |   144 +
 include/gtest/gtest-all.cc                 |  9592 +++++++++++
 include/gtest/gtest.h                      | 20061 ++++++++++++++++++++++
 include/gtest/gtest_main.cc                |    38 +
 include/mshadow/cuda/cuda_reduce.cuh       |   117 +
 include/mshadow/cuda/tensor_gpu-inl.cuh    |   231 +
 include/mshadow/cxxnet_op.h                |   116 +
 include/mshadow/tensor.h                   |   472 +
 include/mshadow/tensor_base.h              |   298 +
 include/mshadow/tensor_container.h         |   152 +
 include/mshadow/tensor_cpu-inl.hpp         |   168 +
 include/mshadow/tensor_expr.h              |   367 +
 include/mshadow/tensor_expr_engine-inl.hpp |   416 +
 include/mshadow/tensor_expr_ext.h          |   978 ++
 include/mshadow/tensor_gpu-inl.hpp         |   148 +
 include/mshadow/tensor_io.h                |   137 +
 include/mshadow/tensor_random.h            |   299 +
 include/mshadow/tensor_sse-inl.hpp         |   431 +
 include/neuralnet/base_layer.h             |   563 +
 include/neuralnet/layer.h                  |   297 +
 include/neuralnet/neuralnet.h              |   156 +
 include/trainer/pm_server.h                |    91 +
 include/trainer/pm_worker.h                |   171 +
 include/trainer/server.h                   |    22 +
 include/trainer/trainer.h                  |    50 +
 include/trainer/worker.h                   |   218 +
 include/utils/blob.h                       |   166 +
 include/utils/cluster.h                    |   125 +
 include/utils/common.h                     |    51 +
 include/utils/data_shard.h                 |   145 +
 include/utils/factory.h                    |    57 +
 include/utils/graph.h                      |   150 +
 include/utils/param.h                      |   172 +
 include/utils/singleton.h                  |    41 +
 include/utils/updater.h                    |    78 +
 script/node.sh                             |    71 +
 src/communication/msg.cc                   |     5 +
 src/communication/socket.cc                |   118 +
 src/main.cc                                |    49 +
 src/neuralnet/base_layer.cc                |   194 +
 src/neuralnet/layer.cc                     |   781 +
 src/neuralnet/neuralnet.cc                 |   401 +
 src/proto/cluster.pb.h                     |   989 ++
 src/proto/cluster.proto                    |    45 +
 src/proto/model.pb.h                       |  8167 +++++++++
 src/proto/model.proto                      |   382 +
 src/test/dist_test/test_consistency.cc     |   406 +
 src/test/dist_test/test_core.cc            |   192 +
 src/test/dist_test/test_da.cc              |   700 +
 src/test/dist_test/test_dary.cc            |    85 +
 src/test/dist_test/test_disk_table.cc      |   188 +
 src/test/dist_test/test_mnistlayer.cc      |   165 +
 src/test/dist_test/test_model.cc           |    25 +
 src/test/dist_test/test_neuralnet.cc       |   141 +
 src/test/dist_test/test_pm.cc              |    88 +
 src/test/dist_test/test_router.cc          |    27 +
 src/test/dist_test/test_split.cc           |   304 +
 src/test/dist_test/test_table_server.cc    |   357 +
 src/test/dist_test/test_tuple.cc           |   258 +
 src/test/model/test_blob.cc                |    58 +
 src/test/model/test_data_layer.cc          |   178 +
 src/test/model/test_label_source.cc        |    59 +
 src/test/model/test_param.cc               |   138 +
 src/test/model/test_proto.cc               |    67 +
 src/test/model/test_rgb_dir_source.cc      |    63 +
 src/test/test_cluster.cc                   |    95 +
 src/test/test_communication.cc             |   158 +
 src/test/test_shard.cc                     |    56 +
 src/trainer/pm_server.cc                   |    99 +
 src/trainer/pm_worker.cc                   |   344 +
 src/trainer/server.cc                      |    68 +
 src/trainer/trainer.cc                     |   206 +
 src/trainer/worker.cc                      |   299 +
 src/utils/blob.cc                          |   330 +
 src/utils/cluster.cc                       |    52 +
 src/utils/common.cc                        |    89 +
 src/utils/data_shard.cc                    |   207 +
 src/utils/graph.cc                         |   148 +
 src/utils/param.cc                         |   345 +
 src/utils/updater.cc                       |   192 +
 95 files changed, 56061 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-singa/blob/b2dc51d2/.gitignore
----------------------------------------------------------------------
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..2d070a5
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,28 @@
+*.orig
+*.swp
+*.o
+*.bin
+*.a
+*.so
+*.dat
+*~
+*.bak
+*.P
+*.odp
+*.project
+*.cproject
+*.log
+*.nfs*
+script/*
+!script/*.sh
+!script/*.awk
+src/test/data/*
+tmp
+log*
+build/
+tmp/
+include/proto/*.h
+src/proto/*.cc
+.sync
+*lmdb
+*.binaryproto

http://git-wip-us.apache.org/repos/asf/incubator-singa/blob/b2dc51d2/LICENSE.md
----------------------------------------------------------------------
diff --git a/LICENSE.md b/LICENSE.md
new file mode 100644
index 0000000..5f43a73
--- /dev/null
+++ b/LICENSE.md
@@ -0,0 +1,864 @@
+Apache License
+                           Version 2.0, January 2004
+                        http://www.apache.org/licenses/
+
+   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+   1. Definitions.
+
+      "License" shall mean the terms and conditions for use, reproduction,
+      and distribution as defined by Sections 1 through 9 of this document.
+
+      "Licensor" shall mean the copyright owner or entity authorized by
+      the copyright owner that is granting the License.
+
+      "Legal Entity" shall mean the union of the acting entity and all
+      other entities that control, are controlled by, or are under common
+      control with that entity. For the purposes of this definition,
+      "control" means (i) the power, direct or indirect, to cause the
+      direction or management of such entity, whether by contract or
+      otherwise, or (ii) ownership of fifty percent (50%) or more of the
+      outstanding shares, or (iii) beneficial ownership of such entity.
+
+      "You" (or "Your") shall mean an individual or Legal Entity
+      exercising permissions granted by this License.
+
+      "Source" form shall mean the preferred form for making modifications,
+      including but not limited to software source code, documentation
+      source, and configuration files.
+
+      "Object" form shall mean any form resulting from mechanical
+      transformation or translation of a Source form, including but
+      not limited to compiled object code, generated documentation,
+      and conversions to other media types.
+
+      "Work" shall mean the work of authorship, whether in Source or
+      Object form, made available under the License, as indicated by a
+      copyright notice that is included in or attached to the work
+      (an example is provided in the Appendix below).
+
+      "Derivative Works" shall mean any work, whether in Source or Object
+      form, that is based on (or derived from) the Work and for which the
+      editorial revisions, annotations, elaborations, or other modifications
+      represent, as a whole, an original work of authorship. For the purposes
+      of this License, Derivative Works shall not include works that remain
+      separable from, or merely link (or bind by name) to the interfaces of,
+      the Work and Derivative Works thereof.
+
+      "Contribution" shall mean any work of authorship, including
+      the original version of the Work and any modifications or additions
+      to that Work or Derivative Works thereof, that is intentionally
+      submitted to Licensor for inclusion in the Work by the copyright owner
+      or by an individual or Legal Entity authorized to submit on behalf of
+      the copyright owner. For the purposes of this definition, "submitted"
+      means any form of electronic, verbal, or written communication sent
+      to the Licensor or its representatives, including but not limited to
+      communication on electronic mailing lists, source code control systems,
+      and issue tracking systems that are managed by, or on behalf of, the
+      Licensor for the purpose of discussing and improving the Work, but
+      excluding communication that is conspicuously marked or otherwise
+      designated in writing by the copyright owner as "Not a Contribution."
+
+      "Contributor" shall mean Licensor and any individual or Legal Entity
+      on behalf of whom a Contribution has been received by Licensor and
+      subsequently incorporated within the Work.
+
+   2. Grant of Copyright License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      copyright license to reproduce, prepare Derivative Works of,
+      publicly display, publicly perform, sublicense, and distribute the
+      Work and such Derivative Works in Source or Object form.
+
+   3. Grant of Patent License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      (except as stated in this section) patent license to make, have made,
+      use, offer to sell, sell, import, and otherwise transfer the Work,
+      where such license applies only to those patent claims licensable
+      by such Contributor that are necessarily infringed by their
+      Contribution(s) alone or by combination of their Contribution(s)
+      with the Work to which such Contribution(s) was submitted. If You
+      institute patent litigation against any entity (including a
+      cross-claim or counterclaim in a lawsuit) alleging that the Work
+      or a Contribution incorporated within the Work constitutes direct
+      or contributory patent infringement, then any patent licenses
+      granted to You under this License for that Work shall terminate
+      as of the date such litigation is filed.
+
+   4. Redistribution. You may reproduce and distribute copies of the
+      Work or Derivative Works thereof in any medium, with or without
+      modifications, and in Source or Object form, provided that You
+      meet the following conditions:
+
+      (a) You must give any other recipients of the Work or
+          Derivative Works a copy of this License; and
+
+      (b) You must cause any modified files to carry prominent notices
+          stating that You changed the files; and
+
+      (c) You must retain, in the Source form of any Derivative Works
+          that You distribute, all copyright, patent, trademark, and
+          attribution notices from the Source form of the Work,
+          excluding those notices that do not pertain to any part of
+          the Derivative Works; and
+
+      (d) If the Work includes a "NOTICE" text file as part of its
+          distribution, then any Derivative Works that You distribute must
+          include a readable copy of the attribution notices contained
+          within such NOTICE file, excluding those notices that do not
+          pertain to any part of the Derivative Works, in at least one
+          of the following places: within a NOTICE text file distributed
+          as part of the Derivative Works; within the Source form or
+          documentation, if provided along with the Derivative Works; or,
+          within a display generated by the Derivative Works, if and
+          wherever such third-party notices normally appear. The contents
+          of the NOTICE file are for informational purposes only and
+          do not modify the License. You may add Your own attribution
+          notices within Derivative Works that You distribute, alongside
+          or as an addendum to the NOTICE text from the Work, provided
+          that such additional attribution notices cannot be construed
+          as modifying the License.
+
+      You may add Your own copyright statement to Your modifications and
+      may provide additional or different license terms and conditions
+      for use, reproduction, or distribution of Your modifications, or
+      for any such Derivative Works as a whole, provided Your use,
+      reproduction, and distribution of the Work otherwise complies with
+      the conditions stated in this License.
+
+   5. Submission of Contributions. Unless You explicitly state otherwise,
+      any Contribution intentionally submitted for inclusion in the Work
+      by You to the Licensor shall be under the terms and conditions of
+      this License, without any additional terms or conditions.
+      Notwithstanding the above, nothing herein shall supersede or modify
+      the terms of any separate license agreement you may have executed
+      with Licensor regarding such Contributions.
+
+   6. Trademarks. This License does not grant permission to use the trade
+      names, trademarks, service marks, or product names of the Licensor,
+      except as required for reasonable and customary use in describing the
+      origin of the Work and reproducing the content of the NOTICE file.
+
+   7. Disclaimer of Warranty. Unless required by applicable law or
+      agreed to in writing, Licensor provides the Work (and each
+      Contributor provides its Contributions) on an "AS IS" BASIS,
+      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+      implied, including, without limitation, any warranties or conditions
+      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+      PARTICULAR PURPOSE. You are solely responsible for determining the
+      appropriateness of using or redistributing the Work and assume any
+      risks associated with Your exercise of permissions under this License.
+
+   8. Limitation of Liability. In no event and under no legal theory,
+      whether in tort (including negligence), contract, or otherwise,
+      unless required by applicable law (such as deliberate and grossly
+      negligent acts) or agreed to in writing, shall any Contributor be
+      liable to You for damages, including any direct, indirect, special,
+      incidental, or consequential damages of any character arising as a
+      result of this License or out of the use or inability to use the
+      Work (including but not limited to damages for loss of goodwill,
+      work stoppage, computer failure or malfunction, or any and all
+      other commercial damages or losses), even if such Contributor
+      has been advised of the possibility of such damages.
+
+   9. Accepting Warranty or Additional Liability. While redistributing
+      the Work or Derivative Works thereof, You may choose to offer,
+      and charge a fee for, acceptance of support, warranty, indemnity,
+      or other liability obligations and/or rights consistent with this
+      License. However, in accepting such obligations, You may act only
+      on Your own behalf and on Your sole responsibility, not on behalf
+      of any other Contributor, and only if You agree to indemnify,
+      defend, and hold each Contributor harmless for any liability
+      incurred by, or claims asserted against, such Contributor by reason
+      of your accepting any such warranty or additional liability.
+
+   END OF TERMS AND CONDITIONS
+
+   APPENDIX: How to apply the Apache License to your work.
+
+      To apply the Apache License to your work, attach the following
+      boilerplate notice, with the fields enclosed by brackets "{}"
+      replaced with your own identifying information. (Don't include
+      the brackets!)  The text should be enclosed in the appropriate
+      comment syntax for the file format. We also recommend that a
+      file or class name and description of purpose be included on the
+      same "printed page" as the copyright notice for easier
+      identification within third-party archives.
+
+   Copyright [yyyy] [name of copyright owner]
+
+   Licensed under the Apache License, Version 2.0 (the "License");
+   you may not use this file except in compliance with the License.
+   You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+============================================================================
+The SINGA project contains subcomponents with separate copyright
+notices and license terms. Your use of the source code for the these
+subcomponents is subject to the terms and conditions of the following
+licenses.
+
+============================================================================
+For cafee (see comments in src/neuralnet/layer.cc)
+===========================================================================
+COPYRIGHT
+All contributions by the University of California:
+Copyright (c) 2014, The Regents of the University of California (Regents)
+All rights reserved.
+All other contributions:
+Copyright (c) 2014, the respective contributors
+All rights reserved.
+Caffe uses a shared copyright model: each contributor holds copyright over
+their contributions to Caffe. The project versioning records all such
+contribution and copyright details. If a contributor wants to further mark
+their specific copyright on a particular contribution, they should indicate
+their copyright solely in the commit message of the change when it is
+committed.
+LICENSE
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+1. Redistributions of source code must retain the above copyright notice, this
+list of conditions and the following disclaimer.
+2. Redistributions in binary form must reproduce the above copyright notice,
+this list of conditions and the following disclaimer in the documentation
+and/or other materials provided with the distribution.
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+CONTRIBUTION AGREEMENT
+By contributing to the BVLC/caffe repository through pull-request, comment,
+or otherwise, the contributor releases their content to the
+license and copyright terms herein.
+
+=====================================================================
+For czmq
+=====================================================================
+Mozilla Public License Version 2.0
+==================================
+
+1. Definitions
+--------------
+
+1.1. "Contributor"
+    means each individual or legal entity that creates, contributes to
+    the creation of, or owns Covered Software.
+
+1.2. "Contributor Version"
+    means the combination of the Contributions of others (if any) used
+    by a Contributor and that particular Contributor's Contribution.
+
+1.3. "Contribution"
+    means Covered Software of a particular Contributor.
+
+1.4. "Covered Software"
+    means Source Code Form to which the initial Contributor has attached
+    the notice in Exhibit A, the Executable Form of such Source Code
+    Form, and Modifications of such Source Code Form, in each case
+    including portions thereof.
+
+1.5. "Incompatible With Secondary Licenses"
+    means
+
+    (a) that the initial Contributor has attached the notice described
+        in Exhibit B to the Covered Software; or
+
+    (b) that the Covered Software was made available under the terms of
+        version 1.1 or earlier of the License, but not also under the
+        terms of a Secondary License.
+
+1.6. "Executable Form"
+    means any form of the work other than Source Code Form.
+
+1.7. "Larger Work"
+    means a work that combines Covered Software with other material, in
+    a separate file or files, that is not Covered Software.
+
+1.8. "License"
+    means this document.
+
+1.9. "Licensable"
+    means having the right to grant, to the maximum extent possible,
+    whether at the time of the initial grant or subsequently, any and
+    all of the rights conveyed by this License.
+
+1.10. "Modifications"
+    means any of the following:
+
+    (a) any file in Source Code Form that results from an addition to,
+        deletion from, or modification of the contents of Covered
+        Software; or
+
+    (b) any new file in Source Code Form that contains any Covered
+        Software.
+
+1.11. "Patent Claims" of a Contributor
+    means any patent claim(s), including without limitation, method,
+    process, and apparatus claims, in any patent Licensable by such
+    Contributor that would be infringed, but for the grant of the
+    License, by the making, using, selling, offering for sale, having
+    made, import, or transfer of either its Contributions or its
+    Contributor Version.
+
+1.12. "Secondary License"
+    means either the GNU General Public License, Version 2.0, the GNU
+    Lesser General Public License, Version 2.1, the GNU Affero General
+    Public License, Version 3.0, or any later versions of those
+    licenses.
+
+1.13. "Source Code Form"
+    means the form of the work preferred for making modifications.
+
+1.14. "You" (or "Your")
+    means an individual or a legal entity exercising rights under this
+    License. For legal entities, "You" includes any entity that
+    controls, is controlled by, or is under common control with You. For
+    purposes of this definition, "control" means (a) the power, direct
+    or indirect, to cause the direction or management of such entity,
+    whether by contract or otherwise, or (b) ownership of more than
+    fifty percent (50%) of the outstanding shares or beneficial
+    ownership of such entity.
+
+2. License Grants and Conditions
+--------------------------------
+
+2.1. Grants
+
+Each Contributor hereby grants You a world-wide, royalty-free,
+non-exclusive license:
+
+(a) under intellectual property rights (other than patent or trademark)
+    Licensable by such Contributor to use, reproduce, make available,
+    modify, display, perform, distribute, and otherwise exploit its
+    Contributions, either on an unmodified basis, with Modifications, or
+    as part of a Larger Work; and
+
+(b) under Patent Claims of such Contributor to make, use, sell, offer
+    for sale, have made, import, and otherwise transfer either its
+    Contributions or its Contributor Version.
+
+2.2. Effective Date
+
+The licenses granted in Section 2.1 with respect to any Contribution
+become effective for each Contribution on the date the Contributor first
+distributes such Contribution.
+
+2.3. Limitations on Grant Scope
+
+The licenses granted in this Section 2 are the only rights granted under
+this License. No additional rights or licenses will be implied from the
+distribution or licensing of Covered Software under this License.
+Notwithstanding Section 2.1(b) above, no patent license is granted by a
+Contributor:
+
+(a) for any code that a Contributor has removed from Covered Software;
+    or
+
+(b) for infringements caused by: (i) Your and any other third party's
+    modifications of Covered Software, or (ii) the combination of its
+    Contributions with other software (except as part of its Contributor
+    Version); or
+
+(c) under Patent Claims infringed by Covered Software in the absence of
+    its Contributions.
+
+This License does not grant any rights in the trademarks, service marks,
+or logos of any Contributor (except as may be necessary to comply with
+the notice requirements in Section 3.4).
+
+2.4. Subsequent Licenses
+
+No Contributor makes additional grants as a result of Your choice to
+distribute the Covered Software under a subsequent version of this
+License (see Section 10.2) or under the terms of a Secondary License (if
+permitted under the terms of Section 3.3).
+
+2.5. Representation
+
+Each Contributor represents that the Contributor believes its
+Contributions are its original creation(s) or it has sufficient rights
+to grant the rights to its Contributions conveyed by this License.
+
+2.6. Fair Use
+
+This License is not intended to limit any rights You have under
+applicable copyright doctrines of fair use, fair dealing, or other
+equivalents.
+
+2.7. Conditions
+
+Sections 3.1, 3.2, 3.3, and 3.4 are conditions of the licenses granted
+in Section 2.1.
+
+3. Responsibilities
+-------------------
+
+3.1. Distribution of Source Form
+
+All distribution of Covered Software in Source Code Form, including any
+Modifications that You create or to which You contribute, must be under
+the terms of this License. You must inform recipients that the Source
+Code Form of the Covered Software is governed by the terms of this
+License, and how they can obtain a copy of this License. You may not
+attempt to alter or restrict the recipients' rights in the Source Code
+Form.
+
+3.2. Distribution of Executable Form
+
+If You distribute Covered Software in Executable Form then:
+
+(a) such Covered Software must also be made available in Source Code
+    Form, as described in Section 3.1, and You must inform recipients of
+    the Executable Form how they can obtain a copy of such Source Code
+    Form by reasonable means in a timely manner, at a charge no more
+    than the cost of distribution to the recipient; and
+
+(b) You may distribute such Executable Form under the terms of this
+    License, or sublicense it under different terms, provided that the
+    license for the Executable Form does not attempt to limit or alter
+    the recipients' rights in the Source Code Form under this License.
+
+3.3. Distribution of a Larger Work
+
+You may create and distribute a Larger Work under terms of Your choice,
+provided that You also comply with the requirements of this License for
+the Covered Software. If the Larger Work is a combination of Covered
+Software with a work governed by one or more Secondary Licenses, and the
+Covered Software is not Incompatible With Secondary Licenses, this
+License permits You to additionally distribute such Covered Software
+under the terms of such Secondary License(s), so that the recipient of
+the Larger Work may, at their option, further distribute the Covered
+Software under the terms of either this License or such Secondary
+License(s).
+
+3.4. Notices
+
+You may not remove or alter the substance of any license notices
+(including copyright notices, patent notices, disclaimers of warranty,
+or limitations of liability) contained within the Source Code Form of
+the Covered Software, except that You may alter any license notices to
+the extent required to remedy known factual inaccuracies.
+
+3.5. Application of Additional Terms
+
+You may choose to offer, and to charge a fee for, warranty, support,
+indemnity or liability obligations to one or more recipients of Covered
+Software. However, You may do so only on Your own behalf, and not on
+behalf of any Contributor. You must make it absolutely clear that any
+such warranty, support, indemnity, or liability obligation is offered by
+You alone, and You hereby agree to indemnify every Contributor for any
+liability incurred by such Contributor as a result of warranty, support,
+indemnity or liability terms You offer. You may include additional
+disclaimers of warranty and limitations of liability specific to any
+jurisdiction.
+
+4. Inability to Comply Due to Statute or Regulation
+---------------------------------------------------
+
+If it is impossible for You to comply with any of the terms of this
+License with respect to some or all of the Covered Software due to
+statute, judicial order, or regulation then You must: (a) comply with
+the terms of this License to the maximum extent possible; and (b)
+describe the limitations and the code they affect. Such description must
+be placed in a text file included with all distributions of the Covered
+Software under this License. Except to the extent prohibited by statute
+or regulation, such description must be sufficiently detailed for a
+recipient of ordinary skill to be able to understand it.
+
+5. Termination
+--------------
+
+5.1. The rights granted under this License will terminate automatically
+if You fail to comply with any of its terms. However, if You become
+compliant, then the rights granted under this License from a particular
+Contributor are reinstated (a) provisionally, unless and until such
+Contributor explicitly and finally terminates Your grants, and (b) on an
+ongoing basis, if such Contributor fails to notify You of the
+non-compliance by some reasonable means prior to 60 days after You have
+come back into compliance. Moreover, Your grants from a particular
+Contributor are reinstated on an ongoing basis if such Contributor
+notifies You of the non-compliance by some reasonable means, this is the
+first time You have received notice of non-compliance with this License
+from such Contributor, and You become compliant prior to 30 days after
+Your receipt of the notice.
+
+5.2. If You initiate litigation against any entity by asserting a patent
+infringement claim (excluding declaratory judgment actions,
+counter-claims, and cross-claims) alleging that a Contributor Version
+directly or indirectly infringes any patent, then the rights granted to
+You by any and all Contributors for the Covered Software under Section
+2.1 of this License shall terminate.
+
+5.3. In the event of termination under Sections 5.1 or 5.2 above, all
+end user license agreements (excluding distributors and resellers) which
+have been validly granted by You or Your distributors under this License
+prior to termination shall survive termination.
+
+************************************************************************
+*                                                                      *
+*  6. Disclaimer of Warranty                                           *
+*  -------------------------                                           *
+*                                                                      *
+*  Covered Software is provided under this License on an "as is"       *
+*  basis, without warranty of any kind, either expressed, implied, or  *
+*  statutory, including, without limitation, warranties that the       *
+*  Covered Software is free of defects, merchantable, fit for a        *
+*  particular purpose or non-infringing. The entire risk as to the     *
+*  quality and performance of the Covered Software is with You.        *
+*  Should any Covered Software prove defective in any respect, You     *
+*  (not any Contributor) assume the cost of any necessary servicing,   *
+*  repair, or correction. This disclaimer of warranty constitutes an   *
+*  essential part of this License. No use of any Covered Software is   *
+*  authorized under this License except under this disclaimer.         *
+*                                                                      *
+************************************************************************
+
+************************************************************************
+*                                                                      *
+*  7. Limitation of Liability                                          *
+*  --------------------------                                          *
+*                                                                      *
+*  Under no circumstances and under no legal theory, whether tort      *
+*  (including negligence), contract, or otherwise, shall any           *
+*  Contributor, or anyone who distributes Covered Software as          *
+*  permitted above, be liable to You for any direct, indirect,         *
+*  special, incidental, or consequential damages of any character      *
+*  including, without limitation, damages for lost profits, loss of    *
+*  goodwill, work stoppage, computer failure or malfunction, or any    *
+*  and all other commercial damages or losses, even if such party      *
+*  shall have been informed of the possibility of such damages. This   *
+*  limitation of liability shall not apply to liability for death or   *
+*  personal injury resulting from such party's negligence to the       *
+*  extent applicable law prohibits such limitation. Some               *
+*  jurisdictions do not allow the exclusion or limitation of           *
+*  incidental or consequential damages, so this exclusion and          *
+*  limitation may not apply to You.                                    *
+*                                                                      *
+************************************************************************
+
+8. Litigation
+-------------
+
+Any litigation relating to this License may be brought only in the
+courts of a jurisdiction where the defendant maintains its principal
+place of business and such litigation shall be governed by laws of that
+jurisdiction, without reference to its conflict-of-law provisions.
+Nothing in this Section shall prevent a party's ability to bring
+cross-claims or counter-claims.
+
+9. Miscellaneous
+----------------
+
+This License represents the complete agreement concerning the subject
+matter hereof. If any provision of this License is held to be
+unenforceable, such provision shall be reformed only to the extent
+necessary to make it enforceable. Any law or regulation which provides
+that the language of a contract shall be construed against the drafter
+shall not be used to construe this License against a Contributor.
+
+10. Versions of the License
+---------------------------
+
+10.1. New Versions
+
+Mozilla Foundation is the license steward. Except as provided in Section
+10.3, no one other than the license steward has the right to modify or
+publish new versions of this License. Each version will be given a
+distinguishing version number.
+
+10.2. Effect of New Versions
+
+You may distribute the Covered Software under the terms of the version
+of the License under which You originally received the Covered Software,
+or under the terms of any subsequent version published by the license
+steward.
+
+10.3. Modified Versions
+
+If you create software not governed by this License, and you want to
+create a new license for such software, you may create and use a
+modified version of this License if you rename the license and remove
+any references to the name of the license steward (except to note that
+such modified license differs from this License).
+
+10.4. Distributing Source Code Form that is Incompatible With Secondary
+Licenses
+
+If You choose to distribute Source Code Form that is Incompatible With
+Secondary Licenses under the terms of this version of the License, the
+notice described in Exhibit B of this License must be attached.
+
+Exhibit A - Source Code Form License Notice
+-------------------------------------------
+
+  This Source Code Form is subject to the terms of the Mozilla Public
+  License, v. 2.0. If a copy of the MPL was not distributed with this
+  file, You can obtain one at http://mozilla.org/MPL/2.0/.
+
+If it is not possible or desirable to put the notice in a particular
+file, then You may include the notice in a location (such as a LICENSE
+file in a relevant directory) where a recipient would be likely to look
+for such a notice.
+
+You may add additional accurate notices of copyright ownership.
+
+Exhibit B - "Incompatible With Secondary Licenses" Notice
+---------------------------------------------------------
+
+  This Source Code Form is "Incompatible With Secondary Licenses", as
+  defined by the Mozilla Public License, v. 2.0.
+
+======================================================================
+For gflags:
+======================================================================
+Copyright (c) 2006, Google Inc.
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are
+met:
+
+    * Redistributions of source code must retain the above copyright
+    notice, this list of conditions and the following disclaimer.
+    * Redistributions in binary form must reproduce the above
+    copyright notice, this list of conditions and the following disclaimer
+    in the documentation and/or other materials provided with the
+    distribution.
+    * Neither the name of Google Inc. nor the names of its
+    contributors may be used to endorse or promote products derived from this
+    software without specific prior written permission.
+
+    THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+    AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+    IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+    ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+    LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+    CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+    SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+    INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+    CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+    ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+    POSSIBILITY OF SUCH DAMAGE.
+
+======================================================================
+For glog:
+======================================================================
+Copyright (c) 2008, Google Inc.
+All rights reserved.
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are
+met:
+* Redistributions of source code must retain the above copyright
+notice, this list of conditions and the following disclaimer.
+* Redistributions in binary form must reproduce the above
+copyright notice, this list of conditions and the following disclaimer
+in the documentation and/or other materials provided with the
+distribution.
+* Neither the name of Google Inc. nor the names of its
+contributors may be used to endorse or promote products derived from
+this software without specific prior written permission.
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+A function gettimeofday in utilities.cc is based on
+http://www.google.com/codesearch/p?hl=en#dR3YEbitojA/COPYING&q=GetSystemTimeAsFileTime%20license:bsd
+The license of this code is:
+Copyright (c) 2003-2008, Jouni Malinen <j@w1.fi> and contributors
+All Rights Reserved.
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are
+met:
+1. Redistributions of source code must retain the above copyright
+notice, this list of conditions and the following disclaimer.
+2. Redistributions in binary form must reproduce the above copyright
+notice, this list of conditions and the following disclaimer in the
+documentation and/or other materials provided with the distribution.
+3. Neither the name(s) of the above-listed copyright holder(s) nor the
+names of its contributors may be used to endorse or promote products
+derived from this software without specific prior written permission.
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+=====================================================================
+For lmdb
+=====================================================================
+The OpenLDAP Public License
+  Version 2.8, 17 August 2003
+
+  Redistribution and use of this software and associated documentation
+  ("Software"), with or without modification, are permitted provided
+  that the following conditions are met:
+
+  1. Redistributions in source form must retain copyright statements
+     and notices,
+
+  2. Redistributions in binary form must reproduce applicable copyright
+  statements and notices, this list of conditions, and the following disclaimer
+  in the documentation and/or other materials provided with the distribution,
+  and
+
+  3. Redistributions must contain a verbatim copy of this document.
+
+  The OpenLDAP Foundation may revise this license from time to
+  time.
+  Each revision is distinguished by a version number.  You may use
+  this Software under terms of this license revision or under the
+  terms of any subsequent revision of the license.
+
+  THIS SOFTWARE IS PROVIDED BY THE OPENLDAP FOUNDATION AND ITS
+  CONTRIBUTORS ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
+  INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+  MERCHANTABILITY
+  AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT
+  SHALL THE OPENLDAP FOUNDATION, ITS CONTRIBUTORS, OR THE AUTHOR(S)
+  OR OWNER(S) OF THE SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT,
+  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+  (INCLUDING,
+  BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+  STRICT
+  LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+  ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+  POSSIBILITY OF SUCH DAMAGE.
+
+  The names of the authors and copyright holders must not be used
+  in
+  advertising or otherwise to promote the sale, use or other
+  dealing
+  in this Software without specific, written prior permission.
+  Title
+  to copyright in this Software shall at all times remain with
+  copyright
+  holders.
+
+  OpenLDAP is a registered trademark of the OpenLDAP Foundation.
+
+  Copyright 1999-2003 The OpenLDAP Foundation, Redwood City,
+  California, USA.  All Rights Reserved.  Permission to copy and
+  distribute verbatim copies of this document is granted.
+
+======================================================================
+For protobuf:
+=====================================================================
+Copyright 2008, Google Inc.
+All rights reserved.
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are
+met:
+* Redistributions of source code must retain the above copyright
+notice, this list of conditions and the following disclaimer.
+* Redistributions in binary form must reproduce the above
+copyright notice, this list of conditions and the following disclaimer
+in the documentation and/or other materials provided with the
+distribution.
+* Neither the name of Google Inc. nor the names of its
+contributors may be used to endorse or promote products derived from
+this software without specific prior written permission.
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+Code generated by the Protocol Buffer compiler is owned by the owner
+of the input file used when generating it. This code is not
+standalone and requires a support library to be linked with it. This
+support library is itself covered by the above license.
+
+========================================================================
+For OpenCV used in preprocessing images
+=======================================================================
+License Agreement
+For Open Source Computer Vision Library
+(3-clause BSD License)
+
+Redistribution and use in source and binary forms, with or without modification,
+are permitted provided that the following conditions are met:
+Redistributions of source code must retain the above copyright notice,
+this list of conditions and the following disclaimer.
+Redistributions in binary form must reproduce the above copyright notice,
+this list of conditions and the following disclaimer in the documentation
+and/or other materials provided with the distribution.
+Neither the names of the copyright holders nor the names of the contributors
+may be used to endorse or promote products derived from this software without
+specific prior written permission.
+
+This software is provided by the copyright holders and contributors “as is”
+and any express or implied warranties, including, but not limited to, the
+implied warranties of merchantability and fitness for a particular purpose are
+disclaimed. In no event shall copyright holders or contributors be liable for
+any direct, indirect, incidental, special, exemplary, or consequential damages
+(including, but not limited to, procurement of substitute goods or services;
+loss of use, data, or profits; or business interruption) however caused and on
+any theory of liability, whether in contract, strict liability, or tort
+(including negligence or otherwise) arising in any way out of the use of this
+software, even if advised of the possibility of such damage.
+
+
+========================================================================
+For Openblas
+=======================================================================
+Copyright (c) 2011-2014, The OpenBLAS Project
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are
+met:
+
+  1. Redistributions of source code must retain the above copyright
+         notice, this list of conditions and the following disclaimer.
+
+  2. Redistributions in binary form must reproduce the above copyright notice,
+  this list of conditions and the following disclaimer in the documentation
+  and/or other materials provided with the distribution.
+  3. Neither the name of the OpenBLAS project nor the names of its contributors
+  may be used to endorse or promote products derived from this software without
+  specific prior written permission.
+
+  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+  AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+  ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+  LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+  CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+  SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+  INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+  CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+  POSSIBILITY OF SUCH DAMAGE.

http://git-wip-us.apache.org/repos/asf/incubator-singa/blob/b2dc51d2/Makefile
----------------------------------------------------------------------
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..d29c933
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,90 @@
+###################User Config Varaibles #############################
+HOME_DIR := /usr/
+# Lib folder for system and external libs. You may need to change it.
+LIBRARY_DIRS := $(HOME_DIR)/lib64 $(HOME_DIR)/lib $(HOME_DIR)/local/lib
+# Header folder for system and external libs. You may need to change it.
+INCLUDE_DIRS := $(HOME_DIR)/include ./include
+# g++ location, should support c++11, tested with 4.8.1
+CXX := g++
+
+######################Setting Varialbes#######################################
+LIBRARIES := glog gflags protobuf rt opencv_highgui opencv_imgproc opencv_core\
+	lmdb openblas zmq czmq
+
+LDFLAGS := $(foreach librarydir, $(LIBRARY_DIRS), -L$(librarydir))\
+	$(foreach library, $(LIBRARIES), -l$(library))
+# Folder to store compiled files
+BUILD_DIR := build
+MSHADOW_FLAGS :=-DMSHADOW_USE_CUDA=0 -DMSHADOW_USE_CBLAS=1 -DMSHADOW_USE_MKL=0
+CXXFLAGS := -O2 -Wall -pthread -fPIC -std=c++11 -Wno-unknown-pragmas \
+	$(MSHADOW_FLAGS) -DCPU_ONLY=1 \
+	-funroll-loops $(foreach includedir, $(INCLUDE_DIRS), -I$(includedir))
+
+# find user defined .proto file, and then compute the corresponding .h, .cc
+# files, which cannot be found by shell find, because they haven't been
+# generated currently
+PROTOS := $(shell find src/proto/ -name "*.proto")
+PROTO_SRCS :=$(PROTOS:.proto=.pb.cc)
+PROTO_HDRS :=$(patsubst src%, include%, $(PROTOS:.proto=.pb.h))
+PROTO_OBJS :=$(addprefix $(BUILD_DIR)/, $(PROTO_SRCS:.cc=.o))
+
+# each singa src file will generate a .o file
+SINGA_SRCS := $(shell find src/ \( -path "src/test" -o -path "src/main.cc" \) \
+	-prune -o \( -name "*.cc" -type f \) -print )
+SINGA_OBJS := $(sort $(addprefix $(BUILD_DIR)/, $(SINGA_SRCS:.cc=.o)) \
+	$(PROTO_OBJS) )
+-include $(SINGA_OBJS:%.o=%.P)
+
+TEST_SRCS :=$(shell find src/test/ -maxdepth 1 -name "*.cc")
+TEST_OBJS := $(sort $(addprefix $(BUILD_DIR)/, $(TEST_SRCS:.cc=.o)))
+-include $(TEST_OBJS:%.o=%.P)
+
+GTEST_SRC := include/gtest/gtest-all.cc
+GTEST_HDR := include/gtest/gtest.h
+GTEST_LIB := $(BUILD_DIR)/libgtest.a
+
+OBJS := $(sort $(SINGA_OBJS) $(TEST_OBJS) )
+
+########################Compilation Section###################################
+.PHONY: singa test
+
+singa: $(PROTO_OBJS) $(SINGA_OBJS)
+	$(CXX) $(SINGA_OBJS) src/main.cc -o $(BUILD_DIR)/singa $(CXXFLAGS) $(LDFLAGS)
+	@echo
+
+loader: proto $(LOADER_OBJS)
+	$(CXX) $(LOADER_OBJS) -o $(BUILD_DIR)/loader $(CXXFLAGS) $(LDFLAGS)
+	@echo
+
+test:  proto $(GTEST_LIB) $(TEST_OBJS) $(SINGA_OBJS)
+	$(CXX) $(TEST_OBJS) include/gtest/gtest_main.cc $(GTEST_LIB) \
+		$(SINGA_OBJS) -o $(BUILD_DIR)/test $(CXXFLAGS) $(LDFLAGS)
+	@echo
+
+$(GTEST_LIB): $(GTEST_HDR) $(GTEST_SRC)
+	$(CXX) $(GTEST_SRC) -c -o $(BUILD_DIR)/gtest-all.o $(CXXFLAGS)
+	ar -rv $(GTEST_LIB) $(BUILD_DIR)/gtest-all.o
+
+# compile all files
+$(OBJS):$(BUILD_DIR)/%.o : %.cc
+	@mkdir -p $(dir $@)
+	$(CXX) $<  $(CXXFLAGS) -MMD -c -o $@
+	cp $(BUILD_DIR)/$*.d $(BUILD_DIR)/$*.P; \
+	sed -e 's/#.*//' -e 's/^[^:]*: *//' -e 's/ *\\$$//' \
+		-e '/^$$/ d' -e 's/$$/ :/' < $(BUILD_DIR)/$*.d >> $(BUILD_DIR)/$*.P; \
+	rm -f $*.d
+
+proto: $(PROTO_OBJS)
+
+$(PROTO_SRCS): $(PROTOS)
+	protoc --proto_path=src/proto --cpp_out=src/proto $(PROTOS)
+	mkdir -p include/proto/
+	cp src/proto/*.pb.h include/proto/
+	@echo
+
+clean:
+	rm -rf *.a *.so
+	rm -rf include/proto/*
+	rm -rf src/proto/*.pb.h src/proto/*.pb.cc
+	rm -rf $(BUILD_DIR)
+	@echo

http://git-wip-us.apache.org/repos/asf/incubator-singa/blob/b2dc51d2/README.md
----------------------------------------------------------------------
diff --git a/README.md b/README.md
index 9d763f6..31ec68c 100644
--- a/README.md
+++ b/README.md
@@ -1,4 +1,6 @@
-SINGA
+Apache SINGA
 =====
 
 Distributed deep learning system
+
+[Project Page](http://singa.incubator.apache.org)

http://git-wip-us.apache.org/repos/asf/incubator-singa/blob/b2dc51d2/examples/cifar10/cluster.conf
----------------------------------------------------------------------
diff --git a/examples/cifar10/cluster.conf b/examples/cifar10/cluster.conf
new file mode 100644
index 0000000..1953d1d
--- /dev/null
+++ b/examples/cifar10/cluster.conf
@@ -0,0 +1,3 @@
+nworker_groups: 1
+nserver_groups: 1
+workspace: "/data1/wangwei/singa/data/mnist"

http://git-wip-us.apache.org/repos/asf/incubator-singa/blob/b2dc51d2/examples/cifar10/hostfile
----------------------------------------------------------------------
diff --git a/examples/cifar10/hostfile b/examples/cifar10/hostfile
new file mode 100644
index 0000000..83e06e5
--- /dev/null
+++ b/examples/cifar10/hostfile
@@ -0,0 +1,20 @@
+awan-2-26-0
+awan-2-27-0
+awan-2-28-0
+awan-2-29-0
+awan-2-30-0
+awan-2-31-0
+awan-2-32-0
+awan-2-33-0
+awan-2-34-0
+awan-2-35-0
+awan-2-36-0
+awan-2-37-0
+awan-2-38-0
+awan-2-39-0
+awan-2-40-0
+awan-2-41-0
+awan-2-42-0
+awan-2-43-0
+awan-2-44-0
+awan-2-45-0

http://git-wip-us.apache.org/repos/asf/incubator-singa/blob/b2dc51d2/examples/cifar10/model.conf
----------------------------------------------------------------------
diff --git a/examples/cifar10/model.conf b/examples/cifar10/model.conf
new file mode 100644
index 0000000..9979c3b
--- /dev/null
+++ b/examples/cifar10/model.conf
@@ -0,0 +1,219 @@
+name: "cifar10-convnet"
+train_steps: 70000
+test_steps:100
+test_frequency:1000
+display_frequency:50
+updater{
+  momentum:0.9
+  weight_decay:0.004
+  learning_rate_change_method:kFixedStep
+  step:0
+  step:60000
+  step:65000
+  step_lr:0.001
+  step_lr:0.0001
+  step_lr:0.00001
+}
+neuralnet {
+layer {
+  name: "data"
+  type: "kLMDBData"
+  data_param {
+    path: "/home/wangwei/program/singa/examples/cifar10/cifar10_train_lmdb"
+    batchsize: 100
+    random_skip:10000
+  }
+  exclude: kTest
+}
+
+layer {
+  name: "data"
+  type: "kLMDBData"
+  data_param {
+    path: "/home/wangwei/program/singa/examples/cifar10/cifar10_test_lmdb"
+    batchsize: 100
+  }
+  exclude: kTrain
+}
+
+layer{
+  name:"rgb"
+  type: "kRGBImage"
+  srclayers: "data"
+  rgbimage_param {
+    meanfile: "/home/wangwei/program/singa/examples/cifar10/mean.binaryproto"
+  }
+}
+
+layer{
+  name: "label"
+  type: "kLabel"
+  srclayers: "data"
+}
+layer {
+  name: "conv1"
+  type: "kConvolution"
+  srclayers: "rgb"
+  convolution_param {
+    num_filters: 32
+    kernel: 5
+    stride: 1
+    pad:2
+  }
+  param{
+      name: "weight"
+      init_method:kGaussian
+      std:0.0001
+      learning_rate_multiplier:1.0
+    }
+  param{
+      name: "bias"
+      init_method: kConstant
+      learning_rate_multiplier:2.0
+      value:0
+    }
+}
+layer {
+  name: "pool1"
+  type: "kPooling"
+  srclayers: "conv1"
+  pooling_param {
+    pool: MAX
+    kernel: 3
+    stride: 2
+  }
+}
+layer {
+  name: "relu1"
+  type: "kReLU"
+  srclayers:"pool1"
+}
+layer {
+  name: "norm1"
+  type: "kLRN"
+  lrn_param {
+    norm_region: WITHIN_CHANNEL
+    local_size: 3
+    alpha: 5e-05
+    beta: 0.75
+  }
+  srclayers:"relu1"
+}
+layer {
+  name: "conv2"
+  type: "kConvolution"
+  srclayers: "norm1"
+  convolution_param {
+    num_filters: 32
+    kernel: 5
+    stride: 1
+    pad:2
+  }
+  param{
+      name: "weight"
+      init_method:kGaussian
+      std:0.01
+      learning_rate_multiplier:1.0
+    }
+  param{
+      name: "bias"
+      init_method: kConstant
+      learning_rate_multiplier:2.0
+      value:0
+    }
+}
+layer {
+  name: "relu2"
+  type: "kReLU"
+  srclayers:"conv2"
+}
+layer {
+  name: "pool2"
+  type: "kPooling"
+  srclayers: "relu2"
+  pooling_param {
+    pool: MAX
+    kernel: 3
+    stride: 2
+  }
+}
+layer {
+  name: "norm2"
+  type: "kLRN"
+  lrn_param {
+    norm_region: WITHIN_CHANNEL
+    local_size: 3
+    alpha: 5e-05
+    beta: 0.75
+  }
+  srclayers:"pool2"
+}
+layer {
+  name: "conv3"
+  type: "kConvolution"
+  srclayers: "norm2"
+  convolution_param {
+    num_filters: 64
+    kernel: 5
+    stride: 1
+    pad:2
+  }
+  param{
+      name: "weight"
+      init_method:kGaussian
+      std:0.01
+    }
+  param{
+      name: "bias"
+      init_method: kConstant
+      value:0
+    }
+}
+layer {
+  name: "relu3"
+  type: "kReLU"
+  srclayers:"conv3"
+}
+layer {
+  name: "pool3"
+  type: "kPooling"
+  srclayers: "relu3"
+  pooling_param {
+    pool: AVE
+    kernel: 3
+    stride: 2
+  }
+}
+layer {
+  name: "ip1"
+  type: "kInnerProduct"
+  srclayers:"pool3"
+  inner_product_param {
+    num_output: 10
+  }
+  param{
+      name: "weight"
+      init_method:kGaussian
+      std:0.01
+      learning_rate_multiplier:1.0
+      weight_decay_multiplier:250
+    }
+  param{
+      name: "bias"
+      init_method: kConstant
+      learning_rate_multiplier:2.0
+      weight_decay_multiplier:0
+      value:0
+  }
+}
+
+layer{
+  name: "loss"
+  type:"kSoftmaxLoss"
+  softmaxloss_param{
+    topk:1
+  }
+  srclayers:"ip1"
+  srclayers:"label"
+}
+}

http://git-wip-us.apache.org/repos/asf/incubator-singa/blob/b2dc51d2/examples/cifar10/run.sh
----------------------------------------------------------------------
diff --git a/examples/cifar10/run.sh b/examples/cifar10/run.sh
new file mode 100755
index 0000000..eb64047
--- /dev/null
+++ b/examples/cifar10/run.sh
@@ -0,0 +1,50 @@
+#!/bin/bash
+
+if [ $# -ne 2 ];then
+  echo "Usage: run.sh [start|stop] num_procs"
+  exit
+fi
+
+netconf=conv.conf
+
+script_path=`readlink -f $0`
+script_dir=`dirname $script_path`
+example_dir=`dirname $script_dir`
+singa_dir=`dirname $example_dir`
+exec_path=${singa_dir}/build/singa
+host_path=$script_dir/hostfile
+ssh_options="-oStrictHostKeyChecking=no \
+-oUserKnownHostsFile=/dev/null \
+-oLogLevel=quiet"
+
+hosts=(`cat $host_path |cut -d ' ' -f 1`)
+if [ $1 == "start" ]
+then
+  count=0
+  for i in ${hosts[@]}
+  do
+    cmd="touch $singa_dir/$count.lock;\
+      $exec_path \
+      -procsID=$count \
+      -hostfile=$host_path \
+      -cluster_conf=$script_dir/cluster.conf \
+      -model_conf=$script_dir/$netconf; rm -f $singa_dir/$count.lock"
+    echo $cmd
+    ssh $ssh_options $i $cmd &
+    count=$(($count+1))
+    if [ $count -eq $2 ]
+    then
+      exit
+    fi
+  done
+elif [ $1 == "stop" ]
+then
+  for (( idx=$2-1 ; idx>=0 ; idx-- ))
+  do
+    echo "ssh ${hosts[$idx]} \"kill singa\""
+    ssh $ssh_options ${hosts[$idx]} "killall -q singa"
+    sleep 1
+  done
+fi
+
+

http://git-wip-us.apache.org/repos/asf/incubator-singa/blob/b2dc51d2/examples/mnist/batch.sh
----------------------------------------------------------------------
diff --git a/examples/mnist/batch.sh b/examples/mnist/batch.sh
new file mode 100644
index 0000000..ff6b8b4
--- /dev/null
+++ b/examples/mnist/batch.sh
@@ -0,0 +1,41 @@
+#!/bin/bash
+
+for nservers in 1
+do
+  for nthreads in 2 4
+  do
+    for nworkers in 1 2 4 8 16
+    do
+      echo "nworkers: $nworkers" >examples/mnist/cluster.conf
+      echo "nservers: $nservers" >>examples/mnist/cluster.conf
+      echo "nthreads_per_server: $nthreads" >>examples/mnist/cluster.conf
+      echo  "workspace:\" /data1/wangwei/singa\"">>examples/mnist/cluster.conf
+      cat examples/mnist/cluster.conf
+      nprocs=$(($nworkers+$nservers))
+      log=log1k/${nworkers}w${nservers}s${nthreads}t
+      echo  $log $nprocs
+      ./examples/mnist/run.sh start $nprocs >$log 2>&1
+      sleep 4
+
+      while true
+      do
+        nstopped=0
+        to=$(($nprocs-1))
+        for worker in $(eval echo "{0..$to}")
+        do
+          if [ ! -e /home/wangwei/program/singa/$worker.lock ]
+          then
+            echo "$worker.lock is free"
+            nstopped=$(($nstopped+1))
+          fi
+        done
+        if [ $nstopped -eq $(($nprocs)) ]
+        then
+          break
+        else
+          sleep 5
+        fi
+      done
+    done
+  done
+done

http://git-wip-us.apache.org/repos/asf/incubator-singa/blob/b2dc51d2/examples/mnist/cluster.conf
----------------------------------------------------------------------
diff --git a/examples/mnist/cluster.conf b/examples/mnist/cluster.conf
new file mode 100644
index 0000000..1953d1d
--- /dev/null
+++ b/examples/mnist/cluster.conf
@@ -0,0 +1,3 @@
+nworker_groups: 1
+nserver_groups: 1
+workspace: "/data1/wangwei/singa/data/mnist"

http://git-wip-us.apache.org/repos/asf/incubator-singa/blob/b2dc51d2/examples/mnist/conv.conf
----------------------------------------------------------------------
diff --git a/examples/mnist/conv.conf b/examples/mnist/conv.conf
new file mode 100644
index 0000000..5f3bf58
--- /dev/null
+++ b/examples/mnist/conv.conf
@@ -0,0 +1,175 @@
+name: "mnist-conv"
+train_steps: 10000
+test_steps:100
+test_frequency:500
+display_frequency:50
+debug: false
+updater{
+  base_learning_rate:0.01
+  momentum:0.9
+  weight_decay:0.0005
+  gamma:0.0001
+  pow:0.75
+  learning_rate_change_method:kInverse
+}
+neuralnet {
+layer {
+  name: "data"
+  type: "kLMDBData"
+  data_param {
+    path: "/home/wangwei/program/singa/examples/mnist/mnist_train_lmdb"
+    batchsize: 64
+  }
+  exclude: kTest
+}
+
+layer {
+  name: "data"
+  type: "kLMDBData"
+  data_param {
+    path: "/home/wangwei/program/singa/examples/mnist/mnist_test_lmdb"
+    batchsize: 100
+  }
+  exclude: kTrain
+}
+
+layer{
+  name:"mnist"
+  type: "kMnistImage"
+  srclayers: "data"
+  mnist_param {
+#    sigma: 6
+#    alpha: 38
+#    gamma: 15
+#    kernel: 21
+#    elastic_freq:100
+#    beta:15
+#    resize: 29
+    norm_a:255
+  }
+}
+
+
+layer{
+  name: "label"
+  type: "kLabel"
+  srclayers: "data"
+}
+layer {
+  name: "conv1"
+  type: "kConvolution"
+  srclayers: "mnist"
+  convolution_param {
+    num_filters: 20
+    kernel: 5
+    stride: 1
+  }
+  param{
+      name: "weight"
+      init_method:kUniformSqrtFanIn
+      learning_rate_multiplier:1.0
+    }
+  param{
+      name: "bias"
+      init_method: kConstant
+      learning_rate_multiplier:2.0
+      value:0
+    }
+}
+layer {
+  name: "pool1"
+  type: "kPooling"
+  srclayers: "conv1"
+  pooling_param {
+    pool: MAX
+    kernel: 2
+    stride: 2
+  }
+}
+layer {
+  name: "conv2"
+  type: "kConvolution"
+  srclayers: "pool1"
+  convolution_param {
+    num_filters: 50
+    kernel: 5
+    stride: 1
+  }
+  param{
+      name: "weight"
+      init_method:kUniformSqrtFanIn
+      learning_rate_multiplier:1.0
+    }
+  param{
+      name: "bias"
+      init_method: kConstant
+      learning_rate_multiplier:2.0
+      value:0
+    }
+}
+layer {
+  name: "pool2"
+  type: "kPooling"
+  srclayers: "conv2"
+  pooling_param {
+    pool: MAX
+    kernel: 2
+    stride: 2
+  }
+}
+layer {
+  name: "ip1"
+  type: "kInnerProduct"
+  srclayers:"pool2"
+  inner_product_param {
+    num_output: 500
+  }
+  param{
+      name: "weight"
+      init_method:kUniformSqrtFanIn
+      learning_rate_multiplier:1.0
+    }
+  param{
+      name: "bias"
+      init_method: kConstant
+      learning_rate_multiplier:2.0
+      value:0
+  }
+
+}
+
+layer {
+  name: "relu1"
+  type: "kReLU"
+  srclayers:"ip1"
+}
+
+layer {
+  name: "ip2"
+  type: "kInnerProduct"
+  srclayers:"relu1"
+  inner_product_param {
+    num_output: 10
+  }
+  param{
+      name: "weight"
+      init_method:kUniformSqrtFanIn
+      learning_rate_multiplier:1
+    }
+  param{
+      name: "bias"
+      init_method: kConstant
+      learning_rate_multiplier:2
+      value:0
+    }
+}
+layer{
+  name: "loss"
+  type:"kSoftmaxLoss"
+  softmaxloss_param{
+    topk:1
+  }
+  srclayers:"ip2"
+  srclayers:"label"
+}
+}

http://git-wip-us.apache.org/repos/asf/incubator-singa/blob/b2dc51d2/examples/mnist/hostfile
----------------------------------------------------------------------
diff --git a/examples/mnist/hostfile b/examples/mnist/hostfile
new file mode 100644
index 0000000..1781444
--- /dev/null
+++ b/examples/mnist/hostfile
@@ -0,0 +1,8 @@
+192.168.26.10
+192.168.26.11
+192.168.26.12
+192.168.26.13
+192.168.26.15
+192.168.26.16
+192.168.26.17
+192.168.26.18

http://git-wip-us.apache.org/repos/asf/incubator-singa/blob/b2dc51d2/examples/mnist/mlp.conf
----------------------------------------------------------------------
diff --git a/examples/mnist/mlp.conf b/examples/mnist/mlp.conf
new file mode 100644
index 0000000..d0ed08f
--- /dev/null
+++ b/examples/mnist/mlp.conf
@@ -0,0 +1,223 @@
+name: "deep-big-simple-mlp"
+train_steps: 10000
+test_steps:10
+test_frequency:60
+display_frequency:30
+checkpoint_frequency:120
+updater{
+  base_learning_rate: 0.001
+  learning_rate_change_method: kStep
+  learning_rate_change_frequency: 60
+  gamma: 0.997
+  param_type: "Param"
+}
+
+neuralnet {
+layer {
+  name: "data"
+  type: "kLMDBData"
+  data_param {
+    path: "/home/wangwei/program/singa/examples/mnist/mnist_train_lmdb"
+    batchsize: 1000
+    random_skip: 10000
+  }
+  exclude: kTest
+}
+
+layer {
+  name: "data"
+  type: "kLMDBData"
+  data_param {
+    path: "/home/wangwei/program/singa/examples/mnist/mnist_test_lmdb"
+    batchsize: 1000
+  }
+  exclude: kTrain
+}
+
+layer{
+  name:"mnist"
+  type: "kMnistImage"
+  srclayers: "data"
+  mnist_param {
+#    sigma: 6
+#    alpha: 38
+#    gamma: 15
+#    kernel: 21
+#    elastic_freq:100
+#    beta:15
+#    resize: 29
+    norm_a: 127.5
+    norm_b: 1
+  }
+}
+
+
+layer{
+  name: "label"
+  type: "kLabel"
+  srclayers: "data"
+}
+
+layer{
+  name: "fc1"
+  type: "kInnerProduct"
+  srclayers:"mnist"
+  inner_product_param{
+    num_output: 2500
+  }
+  param{
+    name: "weight"
+    init_method: kUniform
+    low:-0.05
+    high:0.05
+  }
+  param{
+    name: "bias"
+    init_method: kUniform
+    low: -0.05
+    high:0.05
+  }
+}
+
+layer{
+  name: "tanh1"
+  type:"kTanh"
+  srclayers:"fc1"
+}
+layer{
+  name: "fc2"
+  type: "kInnerProduct"
+  srclayers:"tanh1"
+  inner_product_param{
+    num_output: 2000
+  }
+  param{
+    name: "weight"
+    init_method: kUniform
+    low:-0.05
+    high:0.05
+  }
+  param{
+    name: "bias"
+    init_method: kUniform
+    low: -0.05
+    high:0.05
+  }
+}
+
+layer{
+  name: "tanh2"
+  type:"kTanh"
+  srclayers:"fc2"
+}
+layer{
+  name: "fc3"
+  type: "kInnerProduct"
+  srclayers:"tanh2"
+  inner_product_param{
+    num_output: 1500
+  }
+  param{
+    name: "weight"
+    init_method: kUniform
+    low:-0.05
+    high:0.05
+  }
+  param{
+    name: "bias"
+    init_method: kUniform
+    low: -0.05
+    high:0.05
+  }
+
+}
+
+layer{
+  name: "tanh3"
+  type:"kTanh"
+  srclayers:"fc3"
+}
+layer{
+  name: "fc4"
+  type: "kInnerProduct"
+  srclayers:"tanh3"
+  inner_product_param{
+    num_output: 1000
+  }
+  param{
+    name: "weight"
+    init_method: kUniform
+    low:-0.05
+    high:0.05
+  }
+  param{
+    name: "bias"
+    init_method: kUniform
+    low: -0.05
+    high:0.05
+  }
+
+}
+
+layer{
+  name: "tanh4"
+  type:"kTanh"
+  srclayers:"fc4"
+}
+layer{
+  name: "fc5"
+  type: "kInnerProduct"
+  srclayers:"tanh4"
+  inner_product_param{
+    num_output: 500
+  }
+  param{
+    name: "weight"
+    init_method: kUniform
+    low:-0.05
+    high:0.05
+  }
+  param{
+    name: "bias"
+    init_method: kUniform
+    low: -0.05
+    high:0.05
+  }
+
+}
+
+layer{
+  name: "tanh5"
+  type:"kTanh"
+  srclayers:"fc5"
+}
+layer{
+  name: "fc6"
+  type: "kInnerProduct"
+  srclayers:"tanh5"
+  inner_product_param{
+    num_output: 10
+  }
+  param{
+    name: "weight"
+    init_method: kUniform
+    low:-0.05
+    high:0.05
+  }
+  param{
+    name: "bias"
+    init_method: kUniform
+    low: -0.05
+    high:0.05
+  }
+}
+layer{
+  name: "loss"
+  type:"kSoftmaxLoss"
+  softmaxloss_param{
+    topk:1
+  }
+  srclayers:"fc6"
+  srclayers:"label"
+}
+}

http://git-wip-us.apache.org/repos/asf/incubator-singa/blob/b2dc51d2/examples/mnist/run.sh
----------------------------------------------------------------------
diff --git a/examples/mnist/run.sh b/examples/mnist/run.sh
new file mode 100755
index 0000000..1b16ca9
--- /dev/null
+++ b/examples/mnist/run.sh
@@ -0,0 +1,40 @@
+#!/bin/bash
+
+if [ $# -ne 2 ];then
+  echo "Usage: run.sh [start|stop] num_procs"
+  exit
+fi
+
+script_path=`readlink -f $0`
+script_dir=`dirname $script_path`
+example_dir=`dirname $script_dir`
+singa_dir=`dirname $example_dir`
+exec_path=${singa_dir}/build/pm
+host_path=$script_dir/hostfile
+model_path=$script_dir/mlp.conf
+cluster_path=$script_dir/cluster.conf
+ssh_options="-oStrictHostKeyChecking=no \
+-oUserKnownHostsFile=/dev/null"
+
+hosts=(`cat $host_path |cut -d ' ' -f 1`)
+params=(`cat $host_path | cut -d ' ' -f 2`)
+if [ $1 == "start" ]
+then
+  rm -rf $singa_dir/log*
+  for (( i=0; i<$2; i++ ))
+  do
+   	cmd="source ~/.bash_profile; touch $singa_dir/$i.lock;\
+      $exec_path  --hostfile=$script_dir/hostfile --procs_id=$i\
+      --model=${modelfile} --cluster=${clusterfile}"
+    echo ${hosts[$i]} $ssh_options  $cmd
+    ssh $ssh_options ${hosts[$i]} $cmd &
+  done
+elif [ $1 == "stop" ]
+then
+  for (( idx=0 ; idx<$2 ; idx++ ))
+  do
+    echo "ssh ${hosts[$idx]} \"kill pm\""
+    ssh $ssh_options ${hosts[$idx]} "killall -q pm"
+    sleep 1
+  done
+fi

http://git-wip-us.apache.org/repos/asf/incubator-singa/blob/b2dc51d2/include/communication/msg.h
----------------------------------------------------------------------
diff --git a/include/communication/msg.h b/include/communication/msg.h
new file mode 100644
index 0000000..54b4601
--- /dev/null
+++ b/include/communication/msg.h
@@ -0,0 +1,187 @@
+#ifndef INCLUDE_COMMUNICATION_MSG_H_
+#define INCLUDE_COMMUNICATION_MSG_H_
+#include <string>
+#include <czmq.h>
+#include <glog/logging.h>
+
+using std::string;
+namespace singa {
+class BaseMsg{
+  public:
+  /**
+    * Destructor to free memory
+    */
+  virtual ~BaseMsg(){};
+  /**
+    * @param group_id worker/server group id
+    * @param id worker/server id within the group
+    * @param flag 0 for server, 1 for worker, 2 for stub
+    */
+  virtual void set_src(int group_id, int id, int flag)=0;
+  virtual void set_dst(int group_id, int id, int flag)=0;
+  virtual void set_src(int procs_id, int flag)=0;
+  virtual void set_dst(int procs_id, int flag)=0;
+  virtual int src_group_id() const=0;
+  virtual int dst_group_id() const=0;
+  virtual int src_id() const=0;
+  virtual int dst_id() const=0;
+  virtual int src_flag() const=0;
+  virtual int dst_flag() const=0;
+  virtual void set_type(int type)=0;
+  virtual int type() const=0;
+  virtual void set_target(int target)=0;
+  virtual int target() const=0;
+
+  /**
+   * Copy src and dst address, including group_id, id, flag
+   */
+  virtual BaseMsg* CopyAddr()=0;
+  virtual void SetAddr(BaseMsg* msg)=0;
+
+  /**
+   * Add a frame (a chunck of bytes) into the message
+   */
+  virtual void add_frame(const void*, int nBytes)=0;
+  virtual int frame_size()=0;
+  virtual void* frame_data()=0;
+  /**
+    * Move the cursor to the next frame
+    * @return true if the next frame is not NULL; otherwise false
+    */
+  virtual bool next_frame()=0;
+};
+
+// TODO make it a compiler argument
+#define USE_ZMQ
+
+#ifdef USE_ZMQ
+class Msg : public BaseMsg{
+ public:
+  Msg() {
+    msg_=zmsg_new();
+  }
+  virtual ~Msg(){
+    if(msg_!=NULL)
+      zmsg_destroy(&msg_);
+  }
+  virtual void set_src(int group_id, int id, int flag){
+    src_=(group_id<<kOff1)|(id<<kOff2)|flag;
+  }
+  virtual void set_dst(int group_id, int id, int flag){
+    dst_=(group_id<<kOff1)|(id<<kOff2)|flag;
+  }
+  virtual void set_src(int procs_id, int flag){
+    set_src(procs_id, 0, flag);
+  }
+  virtual void set_dst(int procs_id, int flag){
+    set_dst(procs_id, 0, flag);
+  }
+  int src() const {
+    return src_;
+  }
+  int dst() const {
+    return dst_;
+  }
+  virtual int src_group_id() const {
+    int ret=src_>>kOff1;
+    return ret;
+  }
+
+  virtual int dst_group_id() const{
+    int ret=dst_>>kOff1;
+    return ret;
+  }
+  virtual int src_id() const{
+    int ret=(src_&kMask1)>>kOff2;
+    return ret;
+  }
+  virtual int dst_id() const{
+    int ret=(dst_&kMask1)>>kOff2;
+    return ret;
+  }
+  virtual int src_flag() const{
+    int ret=src_&kMask2;
+    return ret;
+  }
+  virtual int dst_flag() const{
+    int ret=dst_&kMask2;
+    return ret;
+  }
+
+  void SwapAddr(){
+    std::swap(src_,dst_);
+  }
+
+  virtual void set_type(int type){
+    target_=(type<<kOff3)|(target_&kMask3);
+  }
+  virtual void set_target(int target){
+    target_=(target_>>kOff3)<<kOff3;
+    target_=target_|target;
+  }
+  virtual int type() const{
+    int ret=target_>>kOff3;
+    return ret;
+  }
+  virtual int target() const{
+    int ret=target_&kMask3;
+    return ret;
+  }
+
+  virtual BaseMsg* CopyAddr(){
+    Msg* msg=new Msg();
+    msg->src_=src_;
+    msg->dst_=dst_;
+    return msg;
+  }
+
+  virtual void SetAddr(BaseMsg* msg){
+    src_=(static_cast<Msg*>(msg))->src_;
+    dst_=(static_cast<Msg*>(msg))->dst_;
+  }
+
+  virtual void add_frame(const void* addr, int nBytes){
+    zmsg_addmem(msg_, addr, nBytes);
+  }
+  virtual int frame_size(){
+    return zframe_size(frame_);
+  }
+
+  virtual void* frame_data(){
+    return zframe_data(frame_);
+  }
+
+  virtual bool next_frame(){
+    frame_=zmsg_next(msg_);
+    return frame_!=NULL;
+  }
+
+  void ParseFromZmsg(zmsg_t* msg){
+    char* tmp=zmsg_popstr(msg);
+    sscanf(tmp, "%d %d %d", &src_, &dst_, &target_);
+    //LOG(ERROR)<<"recv "<<src_<<" "<<dst_<<" "<<target_;
+    frame_=zmsg_next(msg);
+    msg_=msg;
+  }
+
+  zmsg_t* DumpToZmsg(){
+    zmsg_pushstrf(msg_, "%d %d %d",src_, dst_,target_);
+    //LOG(ERROR)<<"send "<<src_<<" "<<dst_<<" "<<target_;
+    zmsg_t* tmp=msg_;
+    msg_=NULL;
+    return tmp;
+  }
+
+ protected:
+  static const unsigned int kOff1=16, kOff2=4, kOff3=24;
+  static const unsigned int kMask1=(1<<kOff1)-1, kMask2=(1<<kOff2)-1,
+               kMask3=(1<<kOff3)-1;
+  unsigned int src_, dst_, target_;
+  zmsg_t* msg_;
+  zframe_t *frame_;
+};
+#endif
+
+} /* singa */
+
+#endif // INCLUDE_COMMUNICATION_MSG_H_

http://git-wip-us.apache.org/repos/asf/incubator-singa/blob/b2dc51d2/include/communication/socket.h
----------------------------------------------------------------------
diff --git a/include/communication/socket.h b/include/communication/socket.h
new file mode 100644
index 0000000..771c3da
--- /dev/null
+++ b/include/communication/socket.h
@@ -0,0 +1,144 @@
+#ifndef INCLUDE_COMMUNICATION_SOCKET_H_
+#define INCLUDE_COMMUNICATION_SOCKET_H_
+#include <map>
+#include <vector>
+#include "communication/msg.h"
+namespace singa {
+
+const string kInprocRouterEndpoint="inproc://router";
+class Socket{
+  public:
+  Socket(){}
+  virtual ~Socket(){}
+  /**
+    * Send a message to connected socket(s), non-blocking. The message will
+    * be deallocated after sending, thus should not be used after calling Send();
+    * @param  the message to be sent
+    * @return 1 for success queuing the message for sending, 0 for failure
+    */
+  virtual int Send(Msg* msg)=0;
+  /**
+    * Receive a message from any connected socket.
+    *
+    * @return a message pointer if success; nullptr if failure
+    */
+  virtual Msg* Receive()=0;
+  /**
+   * @return Identifier of the implementation dependent socket. E.g., zsock_t*
+   * for ZeroMQ implementation and rank for MPI implementation.
+   */
+  virtual void* InternalID() const=0;
+
+ protected:
+  int local_id_;
+};
+
+class BasePoller{
+ public:
+  /**
+    * Add a socket for polling; Multiple sockets can be polled together by
+    * adding them into the same poller.
+    */
+  virtual void Add(Socket* socket)=0;
+  /**
+    * Poll for all sockets added into this poller.
+    * @param timeout stop after this number of mseconds
+    * @return pointer to the socket if it has one message in the receiving
+    * queue; nullptr if no message in any sockets,
+    */
+  virtual Socket* Wait(int timeout)=0;
+};
+
+#define USE_ZMQ
+#include <czmq.h>
+
+#ifdef USE_ZMQ
+class Poller: public BasePoller{
+ public:
+  Poller();
+  virtual void Add(Socket* socket);
+  virtual Socket* Wait(int duration);
+ protected:
+  zpoller_t *poller_;
+  std::map<zsock_t*, Socket*> zsock2Socket_;
+};
+
+class Dealer : public Socket{
+ public:
+  /*
+   * @param id local dealer ID within a procs if the dealer is from worker or
+   * server thread, starts from 1 (0 is used by the router); or the connected
+   * remote procs ID for inter-process dealers from the stub thread.
+   */
+  Dealer(int id=-1);
+  virtual ~Dealer();
+  /**
+    * Setup the connection with the router.
+    *
+    * @param endpoint identifier of the router. For intra-process
+    * connection, the endpoint follows the format of ZeroMQ, i.e.,
+    * starting with "inproc://"; in Singa, since each process has one
+    * router, hence we can fix the endpoint to be "inproc://router" for
+    * intra-process. For inter-process, the endpoint follows ZeroMQ's
+    * format, i.e., IP:port, where IP is the connected process.
+    * @return 1 connection sets up successfully; 0 otherwise
+    */
+  virtual int Connect(string endpoint);
+  virtual int Send(Msg* msg);
+  virtual Msg* Receive();
+  virtual void* InternalID() const{
+    return dealer_;
+  }
+ protected:
+  int id_;
+  zsock_t* dealer_;
+  zpoller_t* poller_;
+};
+
+class Router : public Socket{
+ public:
+  virtual ~Router();
+  /**
+   * Constructor.
+   *
+   * There is only one router per procs, hence its local id is 0 and is not set
+   * explicitly.
+   *
+   * @param bufsize buffer at most this number of messages
+   */
+  Router(int bufsize=100);
+ /**
+  * Setup the connection with dealers.
+  *
+  * It automatically binds to the endpoint for intra-process communication,
+  * i.e., "inproc://router".
+  *
+  * @param endpoint the identifier for the Dealer socket in other process
+  * to connect. It has the format IP:Port, where IP is the host machine.
+  * If endpoint is empty, it means that all connections are
+  * intra-process connection.
+  * @return number of connected dealers.
+  */
+  virtual int Bind(string endpoint);
+ /**
+   * If the destination socket has not connected yet, buffer this the message.
+   */
+  virtual int Send(Msg* msg);
+  virtual Msg* Receive();
+  virtual void* InternalID() const{
+    return router_;
+  }
+ protected:
+  zsock_t* router_;
+  zpoller_t* poller_;
+  std::map<int, zframe_t*> id2addr_;
+  std::map<int, std::vector<zmsg_t*>> bufmsg_;
+  int nBufmsg_, bufsize_;
+};
+
+#elif USE_MPI
+vector<shared_ptr<SafeQueue>> MPIQueues;
+#endif
+} /* singa */
+
+#endif // INCLUDE_COMMUNICATION_SOCKET_H_


Mime
View raw message